スタイル下部プロパティ
例
<button>要素の下部の位置を設定します。
document.getElementById("myBtn").style.bottom = "100px";
定義と使用法
bottomプロパティは、配置された要素の下部の位置を設定または返します。
このプロパティは、パディング、スクロールバー、境界線、マージンなど、要素の下部の位置を指定します。
ヒント: positioned要素は、positionプロパティがrelative、absolute、またはfixedに設定されている要素です。
ヒント:配置された要素の上部の位置を設定または戻すには、topプロパティを使用します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
bottom | Yes | Yes | Yes | Yes | Yes |
構文
一番下のプロパティを返します:
object.style.bottom
一番下のプロパティを設定します。
object.style.bottom = "auto|length|%|initial|inherit"
プロパティ値
Value | Description |
---|---|
auto | Lets the browser set the bottom position. This is default |
length | Defines the bottom position in length units. Negative values are allowed |
% | Sets the bottom position in % of the height of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
技術的な詳細
デフォルト値: | 自動 |
---|---|
戻り値: | 配置された要素の最下部の位置を表す文字列 |
CSSバージョン | CSS2 |
その他の例
例
<div>要素の一番下の位置を設定します。
document.getElementById("myDiv").style.bottom = "10px";
例
負の値の使用-<div>要素の下部の位置を設定します。
document.getElementById("myDiv").style.bottom = "-100px";
例
<div>要素の一番下の位置を返します。
alert(document.getElementById("myDiv").style.bottom);
関連ページ
CSSチュートリアル:CSSポジショニング
CSSリファレンス:下部のプロパティ
❮スタイルオブジェクト