CSS Learning: About Background-position

Source: Internet
Author: User
Tags modify
Css

In Rainer's CSS manual, Background-position wrote:

The default value is: 0% 0%. The background picture is positioned at the top-left corner of the content area where the object does not include patches (padding).
If only one value is specified, the value is used for the horizontal axis. The ordinate will default to 50%. If two values are specified, the second value is used for ordinate.
If you set the value to right center, the background image will be positioned on the right-hand side because it overrides the center value as the horizontal axis value.

It's not all like this, its 2-value roots are automatically judged by semantics.
such as Background-position:left top; and Background-position:top left; the top action in the Y coordinate aligns the background picture, and leave aligns the background picture.

Run Code Box

<style type= "Text/css" >body {background-image:url (logo.gif); Background-position:left top; Background-repeat: No-repeat;} </style>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

Run Code Box

<style type= "Text/css" >body {background-image:url (logo.gif); Background-position:left top; Background-repeat: No-repeat;} </style>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

If background-position:100px left is specified, 100px acts on the Y coordinate because left is already used for x-coordinate, and it is consistent with the Background-position:left 100px effect.

Run Code Box

<style type= "Text/css" >body {background-image:url (logo.gif), background-position:100px left; Background-repeat:no-repeat;} </style>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

Run Code Box

<style type= "Text/css" >body {background-image:url (logo.gif); Background-position:left 100px; Background-repeat:no-repeat;} </style>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.