Javascript Reference
Categories: STYLE

javascript STYLE backgroundPositionX, backgroundPositionY

@March 15, 2008, 1:22 a.m.
backgroundPositionX, backgroundPositionYFirefox/Netscape/NN n/a IE 4 Chrome/Safari/DOM n/a  

Read/Write  

Indicate the top and left locations of the background image relative to the element's content region (plus padding). Useful if you wish to adjust the background image along only one axis while not disturbing the other. The same IE 4 cautions for backgroundPosition apply to these two properties.

 
Example
 
document.getElementById("div3").style.backgroundPositionX = "20px";
document.getElementById("table2").style.backgroundPositionY = "10px;"
 
Value

You should be able to specify percentage values, which are the percentage of the block-level element's box width and height (respectively) at which point the image (or repeated images) begins. Setting percentage values, however, does not always work in IE 4 for Windows (and it doesn't work at all on the Mac), even though they are returned as the default value units. You are safest with pixel values. None of the allowed constants except top and left are recognized.

 
Default

0


Powered by Linode.