レイアウト
要素のdisplayボックスタイプを制御するためのユーティリティ。
クラス | スタイル |
---|---|
inline | display: inline; |
block | display: block; |
inline-block | display: inline-block; |
flow-root | display: flow-root; |
flex | display: flex; |
inline-flex | display: inline-flex; |
grid | display: grid; |
inline-grid | display: inline-grid; |
contents | display: contents; |
table | display: table; |
inline-table | display: inline-table; |
table-caption | display: table-caption; |
table-cell | display: table-cell; |
table-column | display: table-column; |
table-column-group | display: table-column-group; |
table-footer-group | display: table-footer-group; |
table-header-group | display: table-header-group; |
table-row-group | display: table-row-group; |
table-row | display: table-row; |
list-item | display: list-item; |
hidden | display: none; |
sr-only | position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; |
not-sr-only | position: static; width: auto; height: auto; padding: 0; margin: 0; overflow: visible; clip: auto; white-space: normal; |
inline
、inline-block
、およびblock
ユーティリティを使用して、テキストと要素のフローを制御します。
<p> When controlling the flow of text, using the CSS property <span class="inline">display: inline</span> will cause the text inside the element to wrap normally.</p><p> While using the property <span class="inline-block">display: inline-block</span> will wrap the element to prevent the text inside from extending beyond its parent.</p><p> Lastly, using the property <span class="block">display: block</span> will put the element on its own line and fill its parent.</p>
flow-root
ユーティリティを使用して、独自のブロック整形コンテキストを持つブロックレベル要素を作成します。
<div class="p-4"> <div class="flow-root ..."> <div class="my-4 ...">Well, let me tell you something, ...</div> </div> <div class="flow-root ..."> <div class="my-4 ...">Sure, go ahead, laugh if you want...</div> </div></div>
flex
ユーティリティを使用して、ブロックレベルのFlexコンテナを作成します。
<div class="flex items-center"> <img src="path/to/image.jpg" /> <div> <strong>Andrew Alfred</strong> <span>Technical advisor</span> </div></div>
inline-flex
ユーティリティを使用して、テキストと一緒にフローするインラインFlexコンテナを作成します。
今日、ミシガン州ではボトルが10セントで返品できるのに、ここでは5セントにしかならないという事実を利用する方法を一日中調べていました。 クレイマー あらゆる可能なアプローチで数値を計算した結果、それがうまくいかないと何度も言ってくるのですが、私はどうにかしてうまくいく方法があると信じなければなりません。ここにはあまりにも多くのチャンスがあるのです。
<p> Today I spent most of the day researching ways to ... <span class="inline-flex items-baseline"> <img src="/img/kramer.jpg" class="mx-1 size-5 self-center rounded-full" /> <span>Kramer</span> </span> keeps telling me there is no way to make it work, that ...</p>
grid
ユーティリティを使用して、グリッドコンテナを作成します。
<div class="grid grid-cols-3 grid-rows-3 gap-4"> <!-- ... --></div>
inline-grid
ユーティリティを使用して、インライングリッドコンテナを作成します。
<span class="inline-grid grid-cols-3 gap-4"> <span>01</span> <span>02</span> <span>03</span> <span>04</span> <span>05</span> <span>06</span></span><span class="inline-grid grid-cols-3 gap-4"> <span>01</span> <span>02</span> <span>03</span> <span>04</span> <span>05</span> <span>06</span></span>
contents
ユーティリティを使用して、子要素が親要素の直接の子要素のように動作する「ファントム」コンテナを作成します。
<div class="flex ..."> <div class="flex-1 ...">01</div> <div class="contents"> <div class="flex-1 ...">02</div> <div class="flex-1 ...">03</div> </div> <div class="flex-1 ...">04</div></div>
table
、table-row
、table-cell
、table-caption
、table-column
、table-column-group
、table-header-group
、table-row-group
、およびtable-footer-group
ユーティリティを使用して、それぞれのテーブル要素のように動作する要素を作成します。
<div class="table w-full ..."> <div class="table-header-group ..."> <div class="table-row"> <div class="table-cell text-left ...">Song</div> <div class="table-cell text-left ...">Artist</div> <div class="table-cell text-left ...">Year</div> </div> </div> <div class="table-row-group"> <div class="table-row"> <div class="table-cell ...">The Sliding Mr. Bones (Next Stop, Pottersville)</div> <div class="table-cell ...">Malcolm Lockyer</div> <div class="table-cell ...">1961</div> </div> <div class="table-row"> <div class="table-cell ...">Witchy Woman</div> <div class="table-cell ...">The Eagles</div> <div class="table-cell ...">1972</div> </div> <div class="table-row"> <div class="table-cell ...">Shining Star</div> <div class="table-cell ...">Earth, Wind, and Fire</div> <div class="table-cell ...">1975</div> </div> </div></div>
hidden
ユーティリティを使用して、ドキュメントから要素を削除します。
<div class="flex ..."> <div class="hidden ...">01</div> <div>02</div> <div>03</div></div>
要素を視覚的に非表示にするが、ドキュメントには残したい場合は、代わりにvisibilityプロパティを使用してください。
sr-only
を使用して、要素をスクリーンリーダーから隠さずに視覚的に非表示にします。
<a href="#"> <svg><!-- ... --></svg> <span class="sr-only">Settings</span></a>
not-sr-only
を使用してsr-only
を元に戻し、要素をスクリーンリーダーだけでなく、目の見えるユーザーにも表示するようにします。
<a href="#"> <svg><!-- ... --></svg> <span class="sr-only sm:not-sr-only">Settings</span></a>
これは、例えば小さな画面では何かを視覚的に非表示にし、大きな画面では表示したい場合に役立ちます。
プレフィックスa display
ユーティリティ md:
のようなブレークポイントバリアントを使用すると、ユーティリティを適用するのはmedium 以上の画面サイズのみになります。
<div class="flex md:inline-flex ..."> <!-- ... --></div>
バリアントの使用方法の詳細については、バリアントのドキュメントを参照してください。