Utilities for controlling how rows are positioned in multi-row flex and grid containers.
<div class="h-48 flex flex-wrap content-start ...">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<div class="h-48 flex flex-wrap content-center ...">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<div class="h-48 flex flex-wrap content-end ...">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
Use content-between
to distribute rows in a container such that there is an equal amount of space between each line:
<div class="h-48 flex flex-wrap content-between ...">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
Use content-around
to distribute rows in a container such that there is an equal amount of space around each line:
<div class="h-48 flex flex-wrap content-around ...">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
Use content-evenly
to distribute rows in a container such that there is an equal amount of space around each item, but also accounting for the doubling of space you would normally see between each item when using content-around
:
<div class="h-48 flex flex-wrap content-evenly ...">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
To control the alignment of flex content at a specific breakpoint, add a {screen}:
prefix to any existing utility class. For example, use md:content-around
to apply the content-around
utility at only medium screen sizes and above.
<div class="content-start md:content-around ...">
<!-- ... -->
</div>
更多有關 Tailwind 響應式設計功能的資訊,可參考 響應式設計 文件。
默認情況下, 只有 響應式 的 align-content 變化模式 (variants) 會產生。
在 tailwind.config.js
的 variants
區塊中變更 alignContent
屬性來決定有哪些變化模式會生成。
舉個例子來說,這個設定將會生成 響應式 和 hover 的變化模式。
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
+ alignContent: ['responsive', 'hover'],
}
}
}
如果你不打算在專案中使用 align-content 功能,可以在你的設定檔裡的 corePlugins
屬性中將 alignContent
設定為 false
來停用功能:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ alignContent: false,
}
}