1. 開発者向けのウェブ技術
  2. CSS
  3. リファレンス
  4. プロパティ
  5. margin-inline-end

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

margin-inline-end

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2020年1月⁩.

* Some parts of this feature may have varying levels of support.

margin-inline-endCSS のプロパティで、要素の論理的なインライン方向の末尾側のマージンを定義し、それが要素の書字方向やテキストの方向に応じて物理的なマージンに対応づけられます。これは margin-top, margin-right, margin-bottom, margin-left の何れかのプロパティに対応し、どれに対応するかは writing-mode, direction, text-orientation で定義された値によって決まります。

試してみましょう

margin-inline-end: 20px;
writing-mode: horizontal-tb;
margin-inline-end: 20px;
writing-mode: vertical-rl;
margin-inline-end: 20%;
writing-mode: horizontal-tb;
direction: rtl;
<section id="default-example">
 <div id="container">
 <div class="col">One</div>
 <div class="col transition-all" id="example-element">Two</div>
 <div class="col">Three</div>
 </div>
</section>
#container {
 width: 300px;
 height: 200px;
 display: flex;
 align-content: flex-start;
 justify-content: flex-start;
}
.col {
 width: 33.33%;
 border: solid #ce7777 10px;
 background-color: #2b3a55;
 color: white;
 flex-shrink: 0;
}
#example-element {
 border: solid 10px #ffbf00;
 background-color: #2b3a55;
 unicode-bidi: bidi-override;
}

構文

css
/* <length> 値 */
margin-inline-end: 10px; /* 絶対的な長さ */
margin-inline-end: 1em; /* テキストの大きさに対する相対値 */
margin-inline-end: 5%; /* 直近のブロックコンテナーの大きさに対する相対値 */
margin-inline-end: anchor-size(height);
margin-inline-end: calc(anchor-size(--myAnchor self-inline, 25px) / 5);
/* キーワード値 */
margin-inline-end: auto;
/* グローバル値 */
margin-inline-end: inherit;
margin-inline-end: initial;
margin-inline-end: revert;
margin-inline-end: revert-layer;
margin-inline-end: unset;

関連プロパティとして、要素の他のマージンを定義する margin-block-start, margin-block-end, margin-inline-start があります。

margin-inline-end プロパティは margin-left プロパティと同じ値を取ります。

公式定義

初期値 0
適用対象margin と同じ
継承 なし
パーセント値レイアウトモデルに依存
計算値 長さで指定されると相当する絶対的な長さ、パーセント値として指定されると指定値、それ以外では auto
アニメーションの種類 length

形式文法

margin-inline-end = 
<'margin-top'>

<margin-top> =
<length-percentage> |
auto |
<anchor-size()>

<length-percentage> =
<length> |
<percentage>

<anchor-size()> =
anchor-size( [ <anchor-name> || <anchor-size> ] ? , <length-percentage>? )

<anchor-name> =
<dashed-ident>

<anchor-size> =
width |
height |
block |
inline |
self-block |
self-inline

インライン方向の末尾側のマージンの設定

HTML

html
<div>
 <p class="exampleText">テキストの例</p>
</div>

CSS

css
div {
 background-color: yellow;
 width: 120px;
 height: 120px;
}
.exampleText {
 writing-mode: vertical-lr;
 margin-inline-end: 20px;
 background-color: #c8c800;
}

結果

仕様書

Specification
CSS Logical Properties and Values Level 1
# margin-properties

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /