Name
background-position — NN n/a IE 4 CSS 2
Synopsis
Inherited: No
Establishes the location of the left and top edges of the background
image specified with the background-image
attribute. The behavior of this attribute can be erratic in Internet
Explorer 4 for the Macintosh.
CSS Syntax
background-position: [percentage
|length
] {1,2} | [top |center |bottom] ||[left | center | right]
Value
You can specify one or two percentages, which are the percentage of
the block-level element’s box width and height (respectively)
at which the image (or repeated images) begins. If you supply only
one percentage value, it applies to the horizontal measure, and the
vertical measure is automatically set to 50%. Instead of percentages,
you can specify length values (in the unit of measure that best suits
the medium). You can also mix a percentage with a length. In lieu of
the numerical values, you can create combinations of values with the
two sets of constant values. Select one from each collection, as in
top left
,
top right
, or
bottom center
. Whenever you
specify two values, they must be separated by a space.
Initial Value
0% 0%
Example
DIV.marked {background-image: url(watermark.jpg); background-position: center top}
Applies To
Block-level and replaced elements.
Object Model Reference
- IE
[window.]document.all.
elementID
.style.backgroundPosition
Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.