CSSの権利プロパティ
例
配置された<div>要素の右端を最も近い配置された祖先の右端の左側に150pxに設定します。
div.absolute {
position: absolute;
right:
150px;
width: 200px;
height: 120px;
border: 3px solid
green;
}
以下の「自分で試してみてください」の例をもっと見てください。
定義と使用法
このright
プロパティは、配置された要素の水平位置に影響します。このプロパティは、配置されていない要素には影響しません。
- 位置の場合:絶対; または位置:固定; -
right
プロパティは、要素の右端を、最も近い位置にある祖先の右端の右側の単位に設定します。 - 位置の場合:相対; -
right
プロパティは、要素の右端を通常の位置の左/右の単位に設定します。 - 位置の場合:粘着性; -
right
プロパティは、要素がビューポートの内側にあるときはその位置が相対的であるように動作し、外側にあるときはその位置が固定されているように動作します。 - 位置の場合:静的; -
right
プロパティは効果がありません。
デフォルト値: | 自動 |
---|---|
遺伝性の: | いいえ |
アニメート可能: | はい。アニメート可能について読む |
バージョン: | CSS2 |
JavaScript構文: | オブジェクト.style.right = "200px" |
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
Property | |||||
---|---|---|---|---|---|
right | 1.0 | 5.5 | 1.0 | 1.0 | 5.0 |
CSS構文
right: auto|length|initial|inherit;
プロパティ値
Value | Description | Play it |
---|---|---|
auto | Lets the browser calculate the right edge position. This is default | |
length | Sets the right edge position in px, cm, etc. Negative values are allowed. Read about length units | |
% | Sets the right edge position in % of containing element. Negative values are allowed | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
その他の例
例
負の値を持ち、祖先が配置されていない要素には、適切なプロパティを使用します。
div.b {
position: absolute;
right: -20px;
width: 100px;
height: 120px;
border: 3px solid blue;
}
div.c {
position: absolute;
right: 150px;
width: 200px;
height: 120px;
border: 3px solid green;
}
関連ページ
CSSチュートリアル:CSSポジショニング
CSSリファレンス:leftプロパティ
CSSリファレンス:下部のプロパティ
CSSリファレンス:トッププロパティ
HTML DOMリファレンス:正しいプロパティ