margin-block-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-block-end は CSS のプロパティで、要素の論理的なインライン方向の末尾側のマージンを定義し、それが要素の書字方向やテキストの方向に応じて物理的なマージンに対応づけられます。
試してみましょう
margin-block-end: 20px; writing-mode: horizontal-tb; margin-block-end: 20px; writing-mode: vertical-rl; margin-block-end: 20%; writing-mode: horizontal-tb; margin-block-end: auto; writing-mode: vertical-lr; <section id="default-example"> <div id="container"> <div class="row">One</div> <div class="row transition-all" id="example-element">Two</div> <div class="row">Three</div> </div> </section> #container { width: 300px; height: 200px; display: flex; align-content: flex-start; flex-direction: column; justify-content: flex-start; } .row { height: 33.33%; display: inline-block; border: solid #ce7777 10px; background-color: #2b3a55; color: #ffffff; flex-shrink: 0; } #example-element { border: solid 10px #ffbf00; background-color: #2b3a55; } 構文
css
/* <length> 値 */ margin-block-end: 10px; /* 絶対的な長さ */ margin-block-end: 1em; /* テキストの大きさに対する相対値 */ margin-block-end: 5%; /* 直近のブロックコンテナーの大きさに対する相対値 */ /* キーワード値 */ margin-block-end: auto; /* グローバル値 */ margin-block-end: inherit; margin-block-end: initial; margin-block-end: revert; margin-block-end: revert-layer; margin-block-end: unset; これは margin-top, margin-right, margin-bottom, margin-left の何れかのプロパティに対応し、どれに対応するかは writing-mode, direction, text-orientation で定義された値によって決まります。
関連プロパティとして、要素の他のマージンを定義する margin-block-start, margin-inline-start, margin-inline-end があります。
値
margin-block-end プロパティは margin-left プロパティと同じ値を取ります。
公式定義
形式文法
margin-block-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-rl; margin-block-end: 20px; background-color: #c8c800; } 結果
仕様書
| Specification |
|---|
| CSS Logical Properties and Values Level 1> # margin-properties> |
ブラウザーの互換性
Loading…
関連情報
- CSS 論理的プロパティと値
- 対応づけ先の物理的なプロパティ:
margin-top,margin-right,margin-bottom,margin-left writing-mode,direction,text-orientation