HTML DOM bottom 屬性
定義和用法
bottom 屬性設(shè)置定位元素下外邊距邊界與其包含塊下邊界之間的偏移。
語(yǔ)法:
Object.style.bottom=auto|%|length
可能的值
值 | 描述 |
---|---|
auto | 默認(rèn)。通過(guò)瀏覽器計(jì)算底部的位置。 |
% | 設(shè)置元素的底邊到最近一個(gè)具有定位設(shè)置父元素的底部邊緣的百分比位置。 |
length | 使用 px、cm 等單位設(shè)置元素的底邊到最近一個(gè)具有定位設(shè)置父元素的底部邊緣的位置?墒褂秘(fù)值。 |
提示和注釋
Note:如果 "position" 屬性的值為 "static",那么設(shè)置 "bottom" 屬性不會(huì)產(chǎn)生任何效果。
實(shí)例
本例對(duì)元素的下邊進(jìn)行設(shè)置:
<html>
<head>
<style type="text/css">
input
{
position:absolute;
}
</style>
<script type="text/javascript">
function setBottomEdge()
{
document.getElementById("b1").style.bottom="100px";
}
</script>
</head>
<body>
<input type="button" id="b1" onclick="setBottomEdge()"
value="Set bottom edge to 100 px" />
</body>
</html>