HTML DOM backgroundPositionX ÊôÐÔ
¶¨ÒåºÍÓ÷¨
backgroundPositionX ÊôÐÔÉèÖñ³¾°Í¼ÏñµÄˮƽλÖá£
Óï·¨£º
Object.style.backgroundPositionX=position
²ÎÊý | ÃèÊö |
---|---|
|
ˮƽλÖᣠ|
x% | ˮƽλÖá£×óÊÇ 0%¡£ÓÒÊÇ 100%¡£ |
xpos | ˮƽλÖá£×óÊÇ 0¡£µ¥Î»ÊÇÏñËØ (0px) »òÆäËû CSS µ¥Î»¡£ |
ʵÀý
±¾Àý¸Ä±äÁ˱³¾°Í¼ÏñµÄˮƽλÖãº
<html>
<head>
<style type="text/css">
body
{
background-color:#FFCC80;
background-image:url(bgdesert.jpg);
background-repeat:no-repeat
}
</style>
<script type="text/javascript">
function changePosition()
{
document.body.style.backgroundPositionX="right";
}
</script>
</head>
<body>
<input type="button" onclick="changePosition()"
value="Change background-image's x-position" />
</body>
</html>