W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
控制 flex 項目放大的功能類
Class
|
Properties
|
---|---|
flex-grow-0 | flex-grow: 0; |
flex-grow | flex-grow: 1; |
使用 ?flex-grow
? 允許一個 flex 項目放大,以填充任何可用空間。
<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
? 阻止一個 flex 項目放大:
<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àn)有的功能類前添加 ?{screen}:
? 前綴。例如,使用 ?md:flex-grow-0
? 僅在中等及以上尺寸屏幕上應用 ?flex-grow-0
? 功能。
<div class="flex ...">
<!-- ... -->
<div class="flex-grow md:flex-grow-0 ...">
Responsive flex item
</div>
<!-- ... -->
</div>
關于 Tailwind 的響應式設計功能的更多信息,請查看 響應式設計 文檔。
默認情況下,Tailwind 提供了兩個 ?flex-grow
? 實用程序。您可以通過編輯 Tailwind 配置的 ?theme.flexGrow
? 部分來更改、添加或刪除這些內容。
// tailwind.config.js
module.exports = {
theme: {
flexGrow: {
'0': 0,
DEFAULT: 1,
DEFAULT: 2,
'1': 1,
}
}
}
默認情況下, 針對 flex grow 功能類,只生成 responsive 變體。
您可以通過修改您的 ?tailwind.config.js
? 文件中的 ?variants
?部分中的 ?flexGrow
?屬性來控制為 flex grow 功能生成哪些變體。
例如,這個配置也將生成 hover and focus 變體:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
flexGrow: ['hover', 'focus'],
}
}
}
如果您不打算在您的項目中使用 flex grow 功能,您可以通過在配置文件的 ?corePlugins
?部分將 ?flexGrow
?屬性設置為 ?false
?來完全禁用它們:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
flexGrow: false,
}
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: