Style 對象
定義和用法
bottom 屬性設定或傳回定位元素的底部位置。
該屬性規定了元素的底部位置,包括:内邊距、滾動條、邊框和外邊距。
提示:一個定位元素是元素的 position 屬性被設定為:relative(相對)、absolute(絕對)或 fixed(固定)。
文法
設定 bottom 屬性:
Object.style.bottom="auto|length|%|inherit"
傳回 bottom 屬性:
Object.style.bottom
值 | 描述 |
---|---|
auto | 預設。通過浏覽器計算底部的位置。 |
length | 使用 px、cm 等機關設定元素的底邊到最近一個具有定位設定父元素的底部邊緣的位置。可使用負值。 |
% | 設定元素的底邊到最近一個具有定位設定父元素的底部邊緣的百分比位置。 |
inherit | bottom 屬性的值從父元素繼承。 |
浏覽器支援

所有主要浏覽器都支援 bottom 屬性。
注意:IE7 及更早的版本不支援 "inherit" 值。IE8 隻有規定了 !DOCTYPE 才支援 "inherit"。IE9 支援 "inherit"。
執行個體
設定按鈕的底部位置:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鳥教程(runoob.com)</title>
<style type="text/css">
#b1{
position:absolute;
}
</style>
<script>
function displayResult(){
document.getElementById("b1").style.bottom="100px";
</script>
</head>
<body>
<input type="button" id="b1" onclick="displayResult()" value="設定底部的位置">
</body>
</html>
Style 對象