height
版本:CSS1 兼容性:IE4+ NS6+ 繼承性:無
語法:
height :
auto
|
length
取值:
auto
:𨪜
默認值
。無特殊定位,根據HTML定位規則分配
length
:𨪜
由浮點數字和單位標識符組成的長度值 | 百分數。百分數是基於父對象的高度。不可為負數。請參閱
長度單位
說明:
檢索或設置對象的高度。
對於
img
對像來說,僅指定此屬性,其
width
值將根據圖片源尺寸等比例縮放。
按照樣式表的規則,對象的實際高度為其下列屬性值之和:
margin-top
+
border-top
+
padding-top
+
height
+
padding-bottom
+
border-bottom
+
margin-bottom
在IE6中使用
!DOCTYPE
聲明指定
standards-compliant mode
可以實現這一點。
而在IE6中如果沒有將
!DOCTYPE
聲明指定
standards-compliant
模式,以及以前的瀏覽器版本,對象的實際高度等於:
margin-top
+
height
+
margin-bottom
此屬性對於
currentStyle
對像而言是只讀的。對於其他對像而言是可讀寫的。
對應的腳本特性為
height
。其值為一字符串,所以不可用於腳本(Scripts)中的計算。請使用
style
對象的
posHeight
,
pixelHeight
,以及對象的
offsetHeight
等特性。
示例:
div { height: 1in; }
div { position:absolute; top:-3px; height:6px; }