W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
用于控制 flex 和 grid 項(xiàng)目如何沿著容器的主軸定位的功能類。
Class
|
Properties
|
---|---|
justify-start | justify-content: flex-start; |
justify-end | justify-content: flex-end; |
justify-center | justify-content: center; |
justify-between | justify-content: space-between; |
justify-around | justify-content: space-around; |
justify-evenly | justify-content: space-evenly; |
使用 ?justify-start
? 讓項(xiàng)目沿著容器主軸的起點(diǎn)對(duì)齊。
<div class="flex justify-start ...">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
使用 ?justify-center
? 讓項(xiàng)目沿著容器主軸的中心點(diǎn)對(duì)齊。
<div class="flex justify-center ...">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
使用 ?justify-end
? 讓項(xiàng)目沿著容器主軸的結(jié)束點(diǎn)對(duì)齊。
<div class="flex justify-end ...">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
使用 ?justify-between
? 讓項(xiàng)目沿著容器主軸排列,并使每個(gè)項(xiàng)目之間的距離相等。
<div class="flex justify-between ...">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
使用 ?justify-around
? 讓項(xiàng)目沿著容器主軸排列,并使每個(gè)項(xiàng)目?jī)蓚?cè)的距離相等。
<div class="flex justify-around ...">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
使用 ?justify-evenly
? 讓項(xiàng)目沿著容器主軸排列,并使每個(gè)項(xiàng)目周圍的距離相等,但不像使用 ?justify-around
? 時(shí)項(xiàng)目之間有雙倍的距離。
<div class="flex justify-evenly ...">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
要在特定的斷點(diǎn)處對(duì) flex 項(xiàng)目應(yīng)用 justify 功能類,請(qǐng)?jiān)谌魏维F(xiàn)有的功能類前添加 ?{screen}:
? 前綴。例如,使用 ?md:justify-between
? 來僅在中等尺寸以上的屏幕應(yīng)用 ?justify-between
? 功能類。
<div class="justify-start md:justify-between ...">
<!-- ... -->
</div>
關(guān)于 Tailwind 的響應(yīng)式設(shè)計(jì)功能的更多信息,請(qǐng)查看 響應(yīng)式設(shè)計(jì) 文檔。
默認(rèn)情況下, 針對(duì) justify-content 功能類,只生成 responsive 變體。
您可以通過修改您的 ?tailwind.config.js
? 文件中的 ?variants
?部分中的 ?justifyContent
?屬性來控制為 justify-content 功能生成哪些變體。
例如,這個(gè)配置也將生成 hover and focus 變體:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
justifyContent: ['hover', 'focus'],
}
}
}
如果您不打算在您的項(xiàng)目中使用 justify-content 功能,您可以通過在配置文件的 ?corePlugins
?部分將 ?justifyContent
?屬性設(shè)置為 ?false
?來完全禁用它們:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
justifyContent: false,
}
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: