スタイル右プロパティ
例
<div>要素の正しい位置を設定します。
document.getElementById("myDIV").style.right = "100px";
定義と使用法
rightプロパティは、配置された要素の正しい位置を設定または返します。
このプロパティは、パディング、スクロールバー、境界線、マージンなど、要素の正しい位置を指定します。
ヒント: positioned要素は、positionプロパティがrelative、absolute、またはfixedに設定されている要素です。
ヒント:配置された要素の左位置を設定または戻すには、leftプロパティを使用します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
right | Yes | Yes | Yes | Yes | Yes |
構文
適切なプロパティを返します。
object.style.right
適切なプロパティを設定します。
object.style.right = "auto|length|%|initial|inherit"
プロパティ値
Value | Description |
---|---|
auto | Lets the browser set the right position. This is default |
length | Defines the right position in length units. Negative values are allowed |
% | Sets the right position in % of the width 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.right = "-100px";
例
<div>要素の正しい位置を返します。
alert(document.getElementById("myDiv").style.right);
関連ページ
CSSチュートリアル:CSSポジショニング
CSSリファレンス:正しいプロパティ
❮スタイルオブジェクト