CSS Background-position Properties

Source: Internet
Author: User

The Background-position property sets the starting position of the background image.

This property sets the position of the background image (defined by Background-image), and the background image will start at this point if it is to be repeated.

Tip: You need to set the Background-attachment property to "fixed" to ensure that the property works correctly in Firefox and Opera.

Default value: 0% 0%
Inheritance: No
Version: CSS1
JavaScript syntax: object.style.backgroundposition= "center"
All browsers support the Background-position property.

Note: The property value "Inherit" is not supported by any version of Internet Explorer, including IE8.


Possible values
Top left
Top Center
Top Right
Center left
Center Center
Center Right
Bottom Left
Bottom Center
Bottom right

If you specify only one keyword, then the second value will be "center". Default value: 0% 0%.

x y% The first value is a horizontal position and the second value is the vertical position. The upper-left corner is 0% 0%. The lower right corner is 100% 100%. If you specify only one value, the other value will be 50%.

xpos ypos The first value is a horizontal position, and the second value is the vertical position. The upper-left corner is 0 0. Units are pixels (0px 0px) or any other CSS unit. If you specify only one value, the other value will be 50%. You can mix the% and position values.

Example 1:

Example 2:


Example 3:

CSS Background-position Properties

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.