inset
inset
は CSS のプロパティで、 top
, right
, bottom
, left
に対応する一括指定です。これは margin
の一括指定における複数値の場合と同じ構文です。
CSS 論理的プロパティの仕様書で定義されているものですが、論理的なオフセットを定義するものではありません。これは物理的なオフセットであり、要素の書字方向やテキストの向きには関係がありません。
css
/* <length> 値 */
inset: 10px; /* すべての辺に適用される値 */
inset: 4px 8px; /* 上/下 左/右 */
inset: 5px 15px 10px; /* 上 左/右 下 */
inset: 2.4em 3em 3em 3em; /* 上 右 下 左 */
/* 包含ブロックの幅 (左/右) または 高さ (上/下) に対する <percentage> */
inset: 10% 5% 5% 5%;
/* キーワード値 */
inset: auto;
/* グローバル値 */
inset: inherit;
inset: initial;
inset: revert;
inset: unset;
構文
値
inset
プロパティは left
プロパティと同じ値を取ります。
公式定義
形式文法
例
要素のオフセットの設定
HTML
html
<div>
<span class="exampleText">テキストの例</span>
</div>
CSS
css
div {
background-color: yellow;
width: 150px;
height: 120px;
position: relative;
}
.exampleText {
writing-mode: sideways-rl;
position: absolute;
inset: 20px 40px 30px 10px;
background-color: #c8c800;
}
結果
仕様書
Specification |
---|
CSS Logical Properties and Values Level 1 # propdef-inset |
ブラウザーの互換性
BCD tables only load in the browser
関連情報
- 個別指定のボックスのオフセットプロパティ:
top
,right
,bottom
,left
- 対応する論理プロパティの一括指定:
inset-block
およびinset-inline
margin
一括指定の複数値の構文