HTML DOM right 属性

HTML DOM Style 对象参考手册

定义和用法

right 属性设置定位元素右外边距边界与其包含块右边界之间的偏移。

语法:

Object.style.right=auto|%|length

可能的值

描述
auto 默认。通过浏览器来计算右侧的位置。
% 设置元素的右边到最近一个具有定位设置父元素的右边缘的百分比位置。
length 使用 px、cm 等单位设置元素的右边到最近一个具有定位设置父元素的右边缘的位置。可使用负值。

提示和注释

注释:如果 "position" 属性的值为 "static",那么设置 "right" 属性不会产生任何效果。

实例

本例对按钮的左边进行设置:

<html>
<head>
<style type="text/css">
input
{
position:absolute;
}
</style>
<script type="text/javascript">
function setRightEdge()
{
document.getElementById("b1").style.right="100px";
}
</script>
</head>
<body>

<input type="button" id="b1" onclick="setRightEdge()"
value="Set right edge to 100 px" />

</body>
</html>

HTML DOM Style 对象参考手册