margin-bottom

設定物件的下邊界高度。

語法

{ margin-bottom: sHeight }

可能的值

sHeight

指定或接收下列其中一個值的變數:

auto

預設值。下邊界設為等於上邊界。

height

浮點數,後面接著絕對單位指示項 ( cmmminptpc ) 或相對單位指示項 ( emexpx )。

如需支援之長度單位的詳細資訊,請參閱長度單位參照

percentage

整數,後面接著百分比符號 (%)。此值為父物件的高度百分比。

此屬性的預設值為 auto ,而且不是繼承屬性。

備註

若為內嵌元素,此屬性的值用來計算周圍內嵌元素的框線區域 (如果有框線區域的話)。這個值不會影響行高的設定。

此屬性可支援負數的邊界,但內嵌物件的上邊界與下邊界除外。

範例

下列範例使用 margin-bottom 屬性來變更物件的邊界。此範例使用 HR 元素作為選取器,並使用 margin1 作為內嵌樣式表中的類別,以設定水平規則的上邊界:

<style>
    hr { margin-bottom: 2cm; }
    .margin1 { margin-bottom: 4cm; }
</style>
</head>
<body>
<hr onclick="this.className='margin1'" ondblclick="this.className=''">
</style>

此範例使用內嵌指令碼,分別在 onclickondblclick 事件發生時設定和重設邊界:

<hr onclick="this.style.margin-bottom='2cm'" 
ondblclick="this.style.margin-bottom=''">

標準資訊

您可以在 Cascading Style Sheets (CSS), Level 1 (CSS1) (階層式樣式表 (CSS) 層級 1 (CSS1)) Ee371227.xtlink_newWindow(zh-tw,Expression.40).png 找到此屬性的定義。

適用範圍

a, abbr, acronym, b, bdo, big, blockquote, body, button, caption, center, cite, code, custom, dd, defaults, del, dfn, div, dl, dt, em, embed, fieldset, font, form, hn, hr, i, iframe, img, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, ins, li, object, ol, p, q, s, span, sub, table, td, th, tt, u, ul, var, xmp

另請參閱

概念

margin
padding