top

設定相對於文件階層中下一個定位物件頂端的物件位置。

語法

{ top: sTop }

可能的值

sTop

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

auto

預設值。以網頁之標準 HTML 版面配置為根據的預設位置。

length

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

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

percentage

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

此屬性的預設值為 auto 。這不是繼承屬性。

備註

top 屬性只能在已設定 position 屬性的情況下使用,否則將會忽略 top 屬性的值。

範例

下列範例使用 top 屬性來變更物件的位置。此範例使用內嵌樣式來設定 DIV 物件的位置:

<div style="position: absolute; top: 100px; ">
. . . </div>

標準資訊

您可以在 Cascading Style Sheets (CSS), Level 2 (CSS2) (階層式樣式表 (CSS) 層級 2 (CSS2)) Ee371283.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

另請參閱

概念

position
left
right
bottom