background-position property
Sets the position of the background-image within the element.
JavaScript page for this property: backgroundPosition. You can find other example(s) there. |
Possible values:
One of the following values: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Description of values:
Background is aligned to the bottom. | |||||||
Background is centered. | |||||||
The horizontal position of the background in length units. For the supported length units, see the length page. | |||||||
The horizontal position is the specified percentage of the width of the object. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
Background is aligned to the left. | |||||||
Background is aligned to the right. | |||||||
Background is aligned to the top. | |||||||
The vertical position of the background in length units. For the supported length units, see the length page. | |||||||
The vertical position is the specified percentage of the height of the object. |
Default: 0% 0%.
If only one value is set and it can be a horizontal position, the vertical position is set to 50%. If the only value cannot be a horizontal position, the horizontal position is set to 50%.
Example HTML code 1:
This example illustrates the use of the background-position property:
|
||||
<head> <style> .example { background-image: url("bg.jpg"); background-repeat: no-repeat; width: 200px; height: 200px; border:1px solid #CCCCCC; } .centerTop { background-position: center top; } .leftBottom { background-position: left bottom; } </style> </head> <body> <div class="example centerTop" style=" float:right;"> The image is at the center top of this division. </div> <div class="example leftBottom"> The image is at the left bottom of this division. </div> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by tags:
a, abbr, acronym, address, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, col, colGroup, dd, del, dfn, dir, div, dl, dt, em, fieldSet, font, form, frame, frameSet, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tr, tt, u, ul, var, xmp
Related pages:
background
background-attachment
background-color
background-image
background-position-x
background-position-y
background-repeat
background-attachment
background-color
background-image
background-position-x
background-position-y
background-repeat
External links:
background-position (MSDN)
background-position (Mozilla Developer Center)
background-position (Safari Reference Library)
background-position (W3C)
background-position (Mozilla Developer Center)
background-position (Safari Reference Library)
background-position (W3C)
User Contributed Comments