HTML DOM marginRight 屬性
定義和用法
marginRight 屬性設(shè)置元素的右外邊距。
語法:
Object.style.marginRight=auto|length|%
可能的值
值 | 描述 |
---|---|
auto | 瀏覽器設(shè)置的外右邊距。 |
length | 定義固定的外右邊距。默認(rèn)值是 0。 |
% | 定義基于父對象總高度的百分比外右邊距。 |
實(shí)例
下面的例子改變了段落的右外邊距:
<html>
<head>
<style type="text/css">
p
{
text-align: right
}
</style>
<script type="text/javascript">
function changeMargin()
{
document.getElementById("p1").style.marginRight="32px";
}
</script>
</head>
<body>
<input type="button" onclick="changeMargin()"
value="Change the right margin of a paragraph" />
<p>This is a paragraph</p>
<p id="p1">This is a paragraph</p>
<p>This is a paragraph</p>
</body>
</html>