top: auto | <length> | <percentage>
默認值:auto
適用于:定位元素。即定義了position為非static
的元素
繼承性:無
動畫性:當值為<length> | <percentage>時
計算值:當position為static
時,計算值是auto
。
為relative
時,如果top
和bottom
都是auto
,則它們的計算值是0
;如果top
和bottom
其中一個為auto
,則auto
相當于另一個的負值,即top = -bottom;如果top
和bottom
的值都不為auto
,則忽略bottom
。
否則在其它情況下,當指定值為<length>時,計算值為指定值,當指定值為<percentage>時,計算值為計算后的絕對值。除去這些情況,都為auto
媒體:視覺
padding
邊界開始計算偏移值Values | IE | Firefox | Chrome | Safari | Opera | iOS Safari | Android Browser | Android Chrome |
---|---|---|---|---|---|---|---|---|
Basic Support | 8.0+ | 40.0+ | 40.0+ | 8.0+ | 40.0+ | 8.0+ | 4.4+ | 28.0+ |
top
和bottom
都定義了非auto
的值,那么 bottom 的計算值將會被設置為 -top (無論是否顯式的定義了 height 或 max-height),它的指定值將被忽略,說白了,你將無法在不指定某個元素高度的情況,通過給元素指定top
和bottom
的方式來進行高度拉伸;