You are here: Reference > CSS > properties > background-position-x

background-position-x property

Browser support:
Specifies the horizontal coordinate of the background-image relative to the upper-left corner of the container object.
This property is not supported by all browsers, so use background-position property instead wherever you can.
JavaScript page for this property: backgroundPositionX. You can find other example(s) there.

Possible values:

 One of the following values: 
Background is horizontally centered.
Background is aligned to the left.
position in length
The horizontal position of the background in length units. For the supported length units, see the length page.
position in percentage
The horizontal position is the specified percentage of the width of the object.
Background is aligned to the right.
Default: 0%.

Example HTML code 1:

This example illustrates the use of the background-position-x property:
        .example {
            background-image: url("bg.jpg");
            background-repeat: no-repeat;
            width: 200px;
            height: 200px;
            border:1px solid #CCCCCC;
            background-position-y: center;

        .left {
            background-position-x: left;

        .right {
            background-position-x: right;
    <div class="example left" style=" float:right;">
        The image is at the left of this division. 

    <div class="example right">
        The image is at the right of this division. 
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content