W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
控制 flex 項(xiàng)目放大的功能類
Class
|
Properties
|
---|---|
flex-grow-0 | flex-grow: 0; |
flex-grow | flex-grow: 1; |
使用 ?flex-grow
? 允許一個(gè) flex 項(xiàng)目放大,以填充任何可用空間。
<div class="flex ...">
<div class="flex-none w-16 h-16 ...">
<!-- This item will not grow -->
</div>
<div class="flex-grow h-16 ...">
<!-- This item will grow -->
</div>
<div class="flex-none w-16 h-16 ...">
<!-- This item will not grow -->
</div>
</div>
使用 ?flex-grow-0
? 阻止一個(gè) flex 項(xiàng)目放大:
<div class="flex ...">
<div class="flex-grow h-16 ...">
<!-- This item will grow -->
</div>
<div class="flex-grow-0 h-16 ...">
<!-- This item will not grow -->
</div>
<div class="flex-grow h-16 ...">
<!-- This item will grow -->
</div>
</div>
要控制 flex 項(xiàng)目在特定斷點(diǎn)處的放大方式,請(qǐng)?jiān)谌魏维F(xiàn)有的功能類前添加 ?{screen}:
? 前綴。例如,使用 ?md:flex-grow-0
? 僅在中等及以上尺寸屏幕上應(yīng)用 ?flex-grow-0
? 功能。
<div class="flex ...">
<!-- ... -->
<div class="flex-grow md:flex-grow-0 ...">
Responsive flex item
</div>
<!-- ... -->
</div>
關(guān)于 Tailwind 的響應(yīng)式設(shè)計(jì)功能的更多信息,請(qǐng)查看 響應(yīng)式設(shè)計(jì) 文檔。
默認(rèn)情況下,Tailwind 提供了兩個(gè) ?flex-grow
? 實(shí)用程序。您可以通過(guò)編輯 Tailwind 配置的 ?theme.flexGrow
? 部分來(lái)更改、添加或刪除這些內(nèi)容。
// tailwind.config.js
module.exports = {
theme: {
flexGrow: {
'0': 0,
DEFAULT: 1,
DEFAULT: 2,
'1': 1,
}
}
}
默認(rèn)情況下, 針對(duì) flex grow 功能類,只生成 responsive 變體。
您可以通過(guò)修改您的 ?tailwind.config.js
? 文件中的 ?variants
?部分中的 ?flexGrow
?屬性來(lái)控制為 flex grow 功能生成哪些變體。
例如,這個(gè)配置也將生成 hover and focus 變體:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
flexGrow: ['hover', 'focus'],
}
}
}
如果您不打算在您的項(xiàng)目中使用 flex grow 功能,您可以通過(guò)在配置文件的 ?corePlugins
?部分將 ?flexGrow
?屬性設(shè)置為 ?false
?來(lái)完全禁用它們:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
flexGrow: 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)系方式:
更多建議: