CSSのmargin-rightプロパティ
例
<p>要素の右マージンを150ピクセルに設定します。
p.ex1 {
margin-right: 150px;
}
以下の「自分で試してみてください」の例をもっと見てください。
定義と使用法
プロパティは、要素のmargin-right
右マージンを設定します。
注:負の値を使用できます。
デフォルト値: | 0 |
---|---|
遺伝性の: | いいえ |
アニメート可能: | はい、個々のプロパティを参照してください。アニメート可能について読む |
バージョン: | CSS1 |
JavaScript構文: | オブジェクト.style.marginRight = "100px" |
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
Property | |||||
---|---|---|---|---|---|
margin-right | 1.0 | 6.0 | 1.0 | 1.0 | 3.5 |
CSS構文
margin-right: length|auto|initial|inherit;
プロパティ値
Value | Description | Play it |
---|---|---|
length | Specifies a fixed right margin in px, pt, cm, etc. Default value is 0px. Read about length units | |
% | Specifies a right margin in percent of the width of the containing element | |
auto | The browser calculates a right margin | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
その他の例
例
<p>要素の右マージンをコンテナの幅の50%に設定します。
p.ex1 {
margin-right: 50%;
}
例
<p>要素の右マージンを15emに設定します。
p.ex1 {
margin-right: 15em;
}
関連ページ
CSSチュートリアル:CSSマージン
HTML DOMリファレンス:marginRightプロパティ