Style bottom 屬性

Style 對象參考手冊 Style 對象

定義和用法

bottom 屬性設置或返回定位元素的底部位置。

該屬性規定了元素的底部位置,包括:內邊距、滾動條、邊框和外邊距。

提示:一個定位元素是元素的 position 屬性被設置為:relative(相對)、absolute(絕對)或 fixed(固定)。

語法

設置 bottom 屬性:

Object.style.bottom="auto|length|%|inherit"

返回 bottom 屬性:

Object.style.bottom

描述
auto 默認。通過流覽器計算底部的位置。
length 使用 px、cm 等單位設置元素的底邊到最近一個具有定位設置父元素的底部邊緣的位置。可使用負值。
% 設置元素的底邊到最近一個具有定位設置父元素的底部邊緣的百分比位置。
inherit bottom 屬性的值從父元素繼承。


流覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要流覽器都支持 bottom 屬性。

注意:IE7 及更早的版本不支持 "inherit" 值。IE8 只有規定了 !DOCTYPE 才支持 "inherit"。IE9 支持 "inherit"。


實例

實例

設置按鈕的底部位置:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.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 對象參考手冊 Style 對象