margin

英[?mɑ:d??n]? ?美[?mɑ:rd??n]??

#n.邊緣,範圍;極限;利潤,盈餘;(版心外)的空白

vt.留邊;成為…的邊;加邊於,圍繞;為…加旁注

複數(shù): margins

left

英[left]? ?美[l?ft]??

adj.左邊的,左側(cè)的;左派的

n.左,左面;[軍]左翼;左派,激進分子

adv.向左;在左邊

v.離開( leave的過去式和過去分詞)

複數(shù): lefts

javascript marginLeft屬性 語法

作用:設定元素的左外邊距。

語法:Object.style.marginLeft=auto|length|%

參數(shù):auto ? ?瀏覽器設定的左外邊距。? ? length ? ?定義固定的左外邊距。預設值是0。? ? % ? ?定義基於父物件總高度的百分比左外邊距。? ??

#

javascript marginLeft屬性 範例

<html>
<head>
<script type="text/javascript">
function changeMargin()
{
document.getElementById("p1").style.marginLeft="32px";
}
</script>
</head>
<body>

<input type="button" onclick="changeMargin()" 
value="Change the left 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>

執(zhí)行實例 ?

點擊 "執(zhí)行實例" 按鈕查看線上實例