位置オフセット
余白値、分数、auto、full を使い、物理的な辺のオフセットを設定します。
inset で、余白値や分数を使い、位置指定された箱を包含ブロックのどの端に置くかを決めます。inset は4辺すべて、inset-x と inset-y はそれぞれ左右と上下、top/right/bottom/left は個別の端を指定します。
クラスと CSS の早見表
| クラスの例 | 期待される宣言 |
|---|---|
inset-4 | top: 1rem; right: 1rem; bottom: 1rem; left: 1rem; |
inset-x-4 | left: 1rem; right: 1rem; |
inset-y-4 | top: 1rem; bottom: 1rem; |
top-0 | top: 0; |
right-0 | right: 0; |
bottom-0 | bottom: 0; |
left-0 | left: 0; |
-top-2 | top: -0.5rem; |
left-nudge | left: var(--zw-spacing-nudge); |
例の設定
すべてのプレビューは spec 1、reset "none"、strict モード、spacingUnit "0.25rem"、ブレークポイントなしを明示した設定から始まります。数値の spacing はこの単位を掛けて解決し、Tailwind のテーマは継承しません。wind-demo クラスはデモ用の自作スタイルで、HTML と一緒に CSS を確認できます。
使い方の例
4辺に同じオフセットを設定
inset-4 は絶対配置された箱の4辺にそれぞれ 1rem の間隔を作ります。
<div class="wind-demo">
<div class="wind-demo-frame relative w-72 h-36">
<div class="absolute inset-4 wind-demo-highlight">Same offset on all four sides</div>
</div>
</div>@layer zw-reset, zw-tokens, zfb-hi, base, components;
@layer zw-tokens {
:root {
--zw-spacing-unit: .25rem;
}
}
.wind-demo {
font: 14px / 1.45 system-ui, sans-serif;
color: #203046;
}
.wind-demo-frame {
border: 1px solid #9aaabd;
background: #f8fafc;
padding: .75rem;
}
.wind-demo-highlight {
background: #f2d794;
color: #493810;
border: 1px solid #b39761;
text-align: center;
}
.absolute {
position: absolute;
}
.relative {
position: relative;
}
.inset-4 {
top: 1rem;
right: 1rem;
bottom: 1rem;
left: 1rem;
}
.h-36 {
height: 9rem;
}
.w-72 {
width: 18rem;
}この例の設定
{
"wind": {
"spec": 1,
"reset": "none",
"strict": true,
"tokens": {
"spacingUnit": "0.25rem"
},
"breakpoints": {},
"defaultTransitionTimingFunction": "ease",
"authoredClasses": {
"wind-demo": true,
"wind-demo-frame": true,
"wind-demo-highlight": true
},
"safelist": {
"docs-preview": [
"absolute",
"h-36",
"inset-4",
"relative",
"w-72"
]
}
}
}デモ用の自作 CSS
.wind-demo { font: 14px/1.45 system-ui, sans-serif; color: #203046; }
.wind-demo-frame { border: 1px solid #9aaabd; background: #f8fafc; padding: 0.75rem; }
.wind-demo-highlight { background: #f2d794; color: #493810; border: 1px solid #b39761; text-align: center; }2辺ずつ指定
inset-x-4 は左右、inset-y-4 は上下の端を動かします。
<div class="wind-demo">
<div class="wind-demo-frame relative w-72 h-36">
<div class="absolute inset-x-4 top-4 h-10 wind-demo-tile">Left and right inset</div>
<div class="absolute inset-y-4 right-4 w-12 wind-demo-alt">Top and bottom inset</div>
</div>
</div>@layer zw-reset, zw-tokens, zfb-hi, base, components;
@layer zw-tokens {
:root {
--zw-spacing-unit: .25rem;
}
}
.wind-demo {
font: 14px / 1.45 system-ui, sans-serif;
color: #203046;
}
.wind-demo-alt {
border-color: #b39761;
background: #efe5cb;
color: #483a1d;
}
.wind-demo-frame {
border: 1px solid #9aaabd;
background: #f8fafc;
padding: .75rem;
}
.wind-demo-tile {
border: 1px solid #849bb3;
background: #dce8f2;
color: #203046;
padding: .5rem;
text-align: center;
}
.absolute {
position: absolute;
}
.relative {
position: relative;
}
.inset-x-4 {
left: 1rem;
right: 1rem;
}
.inset-y-4 {
top: 1rem;
bottom: 1rem;
}
.right-4 {
right: 1rem;
}
.top-4 {
top: 1rem;
}
.h-10 {
height: 2.5rem;
}
.h-36 {
height: 9rem;
}
.w-12 {
width: 3rem;
}
.w-72 {
width: 18rem;
}この例の設定
{
"wind": {
"spec": 1,
"reset": "none",
"strict": true,
"tokens": {
"spacingUnit": "0.25rem"
},
"breakpoints": {},
"defaultTransitionTimingFunction": "ease",
"authoredClasses": {
"wind-demo": true,
"wind-demo-alt": true,
"wind-demo-frame": true,
"wind-demo-tile": true
},
"safelist": {
"docs-preview": [
"absolute",
"h-10",
"h-36",
"inset-x-4",
"inset-y-4",
"relative",
"right-4",
"top-4",
"w-12",
"w-72"
]
}
}
}デモ用の自作 CSS
.wind-demo { font: 14px/1.45 system-ui, sans-serif; color: #203046; }
.wind-demo-alt { border-color: #b39761; background: #efe5cb; color: #483a1d; }
.wind-demo-frame { border: 1px solid #9aaabd; background: #f8fafc; padding: 0.75rem; }
.wind-demo-tile { border: 1px solid #849bb3; background: #dce8f2; color: #203046; padding: 0.5rem; text-align: center; }個別の角に配置
top-0、right-0、bottom-0、left-0 で各タイルを relative 枠の四隅に合わせます。
<div class="wind-demo">
<div class="wind-demo-frame relative w-72 h-36">
<div class="absolute top-0 left-0 size-8 wind-demo-tile">TL</div>
<div class="absolute top-0 right-0 size-8 wind-demo-alt">TR</div>
<div class="absolute bottom-0 left-0 size-8 wind-demo-alt">BL</div>
<div class="absolute bottom-0 right-0 size-8 wind-demo-tile">BR</div>
</div>
</div>@layer zw-reset, zw-tokens, zfb-hi, base, components;
@layer zw-tokens {
:root {
--zw-spacing-unit: .25rem;
}
}
.wind-demo {
font: 14px / 1.45 system-ui, sans-serif;
color: #203046;
}
.wind-demo-alt {
border-color: #b39761;
background: #efe5cb;
color: #483a1d;
}
.wind-demo-frame {
border: 1px solid #9aaabd;
background: #f8fafc;
padding: .75rem;
}
.wind-demo-tile {
border: 1px solid #849bb3;
background: #dce8f2;
color: #203046;
padding: .5rem;
text-align: center;
}
.absolute {
position: absolute;
}
.relative {
position: relative;
}
.bottom-0 {
bottom: 0;
}
.left-0 {
left: 0;
}
.right-0 {
right: 0;
}
.top-0 {
top: 0;
}
.size-8 {
width: 2rem;
height: 2rem;
}
.h-36 {
height: 9rem;
}
.w-72 {
width: 18rem;
}この例の設定
{
"wind": {
"spec": 1,
"reset": "none",
"strict": true,
"tokens": {
"spacingUnit": "0.25rem"
},
"breakpoints": {},
"defaultTransitionTimingFunction": "ease",
"authoredClasses": {
"wind-demo": true,
"wind-demo-alt": true,
"wind-demo-frame": true,
"wind-demo-tile": true
},
"safelist": {
"docs-preview": [
"absolute",
"bottom-0",
"h-36",
"left-0",
"relative",
"right-0",
"size-8",
"top-0",
"w-72"
]
}
}
}デモ用の自作 CSS
.wind-demo { font: 14px/1.45 system-ui, sans-serif; color: #203046; }
.wind-demo-alt { border-color: #b39761; background: #efe5cb; color: #483a1d; }
.wind-demo-frame { border: 1px solid #9aaabd; background: #f8fafc; padding: 0.75rem; }
.wind-demo-tile { border: 1px solid #849bb3; background: #dce8f2; color: #203046; padding: 0.5rem; text-align: center; }負の値と名前付きトークン
-top-2 は上へ 0.5rem 移動し、left-nudge は設定済みの tokens.spacing.nudge を使います。
<div class="wind-demo">
<div class="wind-demo-frame relative w-72 h-36">
<div class="absolute -top-2 left-nudge wind-demo-highlight">Negative top; named left token</div>
</div>
</div>@layer zw-reset, zw-tokens, zfb-hi, base, components;
@layer zw-tokens {
:root {
--zw-spacing-nudge: 1rem;
--zw-spacing-unit: .25rem;
}
}
.wind-demo {
font: 14px / 1.45 system-ui, sans-serif;
color: #203046;
}
.wind-demo-frame {
border: 1px solid #9aaabd;
background: #f8fafc;
padding: .75rem;
}
.wind-demo-highlight {
background: #f2d794;
color: #493810;
border: 1px solid #b39761;
text-align: center;
}
.absolute {
position: absolute;
}
.relative {
position: relative;
}
.left-nudge {
left: var(--zw-spacing-nudge);
}
.-top-2 {
top: -0.5rem;
}
.h-36 {
height: 9rem;
}
.w-72 {
width: 18rem;
}この例の設定
{
"wind": {
"spec": 1,
"reset": "none",
"strict": true,
"tokens": {
"spacingUnit": "0.25rem",
"spacing": {
"nudge": "1rem"
}
},
"breakpoints": {},
"defaultTransitionTimingFunction": "ease",
"authoredClasses": {
"wind-demo": true,
"wind-demo-frame": true,
"wind-demo-highlight": true
},
"safelist": {
"docs-preview": [
"-top-2",
"absolute",
"h-36",
"left-nudge",
"relative",
"w-72"
]
}
}
}デモ用の自作 CSS
.wind-demo { font: 14px/1.45 system-ui, sans-serif; color: #203046; }
.wind-demo-frame { border: 1px solid #9aaabd; background: #f8fafc; padding: 0.75rem; }
.wind-demo-highlight { background: #f2d794; color: #493810; border: 1px solid #b39761; text-align: center; }任意値と名前付きの値
数値オフセットは明示した spacingUnit 0.25rem を使い、4 は 1rem です。0、px、full、auto はトークン不要です。left-nudge のような名前付き値には tokens.spacing が必要です。top-[calc(100%_+_8px)] のような任意値も使えます。-top-2 のように負の値も指定できます。inset 自体は要素を位置指定しません。 left-1/2 のような分数は left: calc(100% * 1 / 2)、-top-1/2 は top: calc(calc(100% * 1 / 2) * -1) を出力します。左右のパーセンテージは包含ブロックの幅、上下は高さを基準にします。分子と分母はそれぞれ 1~1,000,000 の正の整数です。
関連ガイド: ユーティリティの文法 · バリアント
カタログの詳細
inset
| フィールド | 値 |
|---|---|
| カタログ識別子 | v1.inset |
| クラスパターン | inset-<suffix> |
| 文法 | {"acceptedKinds":["keyword","token","scale","fraction","arbitrary"],"arbitraryProperty":"top","allowsFractionSlash":true,"allowsColorOpacity":false} |
| 受け入れる値 | 4 |
| トークンカテゴリ | spacing |
| 負の値の規則 | allowed |
| 競合グループと順位 | inset (3) |
| 並び順の順位 | 0 |
| セレクタの形 | ownElement |
| 仕様バージョン | 1 |
| 出力するプロパティ | top, right, bottom, left |
受け入れる値
| 種類 | 接尾辞 | 出力される値 |
|---|---|---|
keyword | "auto" | "auto" |
keyword | "full" | "100%" |
keyword | "0" | "0" |
keyword | "px" | "1px" |
宣言テンプレート
| プロパティ | 値の種類 | 固定値 |
|---|---|---|
top | resolved | null |
right | resolved | null |
bottom | resolved | null |
left | resolved | null |
カタログの例
| クラスの例 | 期待される宣言 |
|---|---|
inset-0 | top: 0; right: 0; bottom: 0; left: 0 |
inset-x
| フィールド | 値 |
|---|---|
| カタログ識別子 | v1.inset-x |
| クラスパターン | inset-x-<suffix> |
| 文法 | {"acceptedKinds":["keyword","token","scale","fraction","arbitrary"],"arbitraryProperty":"top","allowsFractionSlash":true,"allowsColorOpacity":false} |
| 受け入れる値 | 4 |
| トークンカテゴリ | spacing |
| 負の値の規則 | allowed |
| 競合グループと順位 | inset (3) |
| 並び順の順位 | 1 |
| セレクタの形 | ownElement |
| 仕様バージョン | 1 |
| 出力するプロパティ | left, right |
受け入れる値
| 種類 | 接尾辞 | 出力される値 |
|---|---|---|
keyword | "auto" | "auto" |
keyword | "full" | "100%" |
keyword | "0" | "0" |
keyword | "px" | "1px" |
宣言テンプレート
| プロパティ | 値の種類 | 固定値 |
|---|---|---|
left | resolved | null |
right | resolved | null |
カタログの例
| クラスの例 | 期待される宣言 |
|---|---|
inset-x-0 | left: 0; right: 0 |
inset-y
| フィールド | 値 |
|---|---|
| カタログ識別子 | v1.inset-y |
| クラスパターン | inset-y-<suffix> |
| 文法 | {"acceptedKinds":["keyword","token","scale","fraction","arbitrary"],"arbitraryProperty":"top","allowsFractionSlash":true,"allowsColorOpacity":false} |
| 受け入れる値 | 4 |
| トークンカテゴリ | spacing |
| 負の値の規則 | allowed |
| 競合グループと順位 | inset (3) |
| 並び順の順位 | 1 |
| セレクタの形 | ownElement |
| 仕様バージョン | 1 |
| 出力するプロパティ | top, bottom |
受け入れる値
| 種類 | 接尾辞 | 出力される値 |
|---|---|---|
keyword | "auto" | "auto" |
keyword | "full" | "100%" |
keyword | "0" | "0" |
keyword | "px" | "1px" |
宣言テンプレート
| プロパティ | 値の種類 | 固定値 |
|---|---|---|
top | resolved | null |
bottom | resolved | null |
カタログの例
| クラスの例 | 期待される宣言 |
|---|---|
inset-y-0 | top: 0; bottom: 0 |
bottom
| フィールド | 値 |
|---|---|
| カタログ識別子 | v1.bottom |
| クラスパターン | bottom-<suffix> |
| 文法 | {"acceptedKinds":["keyword","token","scale","fraction","arbitrary"],"arbitraryProperty":"top","allowsFractionSlash":true,"allowsColorOpacity":false} |
| 受け入れる値 | 4 |
| トークンカテゴリ | spacing |
| 負の値の規則 | allowed |
| 競合グループと順位 | inset (3) |
| 並び順の順位 | 2 |
| セレクタの形 | ownElement |
| 仕様バージョン | 1 |
| 出力するプロパティ | bottom |
受け入れる値
| 種類 | 接尾辞 | 出力される値 |
|---|---|---|
keyword | "auto" | "auto" |
keyword | "full" | "100%" |
keyword | "0" | "0" |
keyword | "px" | "1px" |
宣言テンプレート
| プロパティ | 値の種類 | 固定値 |
|---|---|---|
bottom | resolved | null |
カタログの例
| クラスの例 | 期待される宣言 |
|---|---|
bottom-0 | bottom: 0 |
left
| フィールド | 値 |
|---|---|
| カタログ識別子 | v1.left |
| クラスパターン | left-<suffix> |
| 文法 | {"acceptedKinds":["keyword","token","scale","fraction","arbitrary"],"arbitraryProperty":"top","allowsFractionSlash":true,"allowsColorOpacity":false} |
| 受け入れる値 | 4 |
| トークンカテゴリ | spacing |
| 負の値の規則 | allowed |
| 競合グループと順位 | inset (3) |
| 並び順の順位 | 2 |
| セレクタの形 | ownElement |
| 仕様バージョン | 1 |
| 出力するプロパティ | left |
受け入れる値
| 種類 | 接尾辞 | 出力される値 |
|---|---|---|
keyword | "auto" | "auto" |
keyword | "full" | "100%" |
keyword | "0" | "0" |
keyword | "px" | "1px" |
宣言テンプレート
| プロパティ | 値の種類 | 固定値 |
|---|---|---|
left | resolved | null |
カタログの例
| クラスの例 | 期待される宣言 |
|---|---|
left-0 | left: 0 |
right
| フィールド | 値 |
|---|---|
| カタログ識別子 | v1.right |
| クラスパターン | right-<suffix> |
| 文法 | {"acceptedKinds":["keyword","token","scale","fraction","arbitrary"],"arbitraryProperty":"top","allowsFractionSlash":true,"allowsColorOpacity":false} |
| 受け入れる値 | 4 |
| トークンカテゴリ | spacing |
| 負の値の規則 | allowed |
| 競合グループと順位 | inset (3) |
| 並び順の順位 | 2 |
| セレクタの形 | ownElement |
| 仕様バージョン | 1 |
| 出力するプロパティ | right |
受け入れる値
| 種類 | 接尾辞 | 出力される値 |
|---|---|---|
keyword | "auto" | "auto" |
keyword | "full" | "100%" |
keyword | "0" | "0" |
keyword | "px" | "1px" |
宣言テンプレート
| プロパティ | 値の種類 | 固定値 |
|---|---|---|
right | resolved | null |
カタログの例
| クラスの例 | 期待される宣言 |
|---|---|
right-0 | right: 0 |
top
| フィールド | 値 |
|---|---|
| カタログ識別子 | v1.top |
| クラスパターン | top-<suffix> |
| 文法 | {"acceptedKinds":["keyword","token","scale","fraction","arbitrary"],"arbitraryProperty":"top","allowsFractionSlash":true,"allowsColorOpacity":false} |
| 受け入れる値 | 4 |
| トークンカテゴリ | spacing |
| 負の値の規則 | allowed |
| 競合グループと順位 | inset (3) |
| 並び順の順位 | 2 |
| セレクタの形 | ownElement |
| 仕様バージョン | 1 |
| 出力するプロパティ | top |
受け入れる値
| 種類 | 接尾辞 | 出力される値 |
|---|---|---|
keyword | "auto" | "auto" |
keyword | "full" | "100%" |
keyword | "0" | "0" |
keyword | "px" | "1px" |
宣言テンプレート
| プロパティ | 値の種類 | 固定値 |
|---|---|---|
top | resolved | null |
カタログの例
| クラスの例 | 期待される宣言 |
|---|---|
top-0 | top: 0 |