W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
用于控制 flex 項(xiàng)目放大和縮小的功能類。
Class
|
Properties
|
---|---|
flex-1 | flex: 1 1 0%; |
flex-auto | flex: 1 1 auto; |
flex-initial | flex: 0 1 auto; |
flex-none | flex: none; |
使用 ?flex-initial
? 允許 flex 項(xiàng)目在考慮到其初始尺寸的情況下縮小但不放大:
<div class="flex">
<div class="flex-initial ...">
<!-- Won't grow, but will shrink if needed -->
</div>
<div class="flex-initial ...">
<!-- Won't grow, but will shrink if needed -->
</div>
<div class="flex-initial ...">
<!-- Won't grow, but will shrink if needed -->
</div>
</div>
使用 ?flex-1
? 允許 flex 項(xiàng)目根據(jù)需要放大和縮小,忽略其初始尺寸。
<div class="flex">
<div class="flex-1 ...">
<!-- Will grow and shrink as needed without taking initial size into account -->
</div>
<div class="flex-1 ...">
<!-- Will grow and shrink as needed without taking initial size into account -->
</div>
<div class="flex-1 ...">
<!-- Will grow and shrink as needed without taking initial size into account -->
</div>
</div>
使用 ?flex-auto
? 允許一個(gè) flex 項(xiàng)目在考慮到其初始大小的情況下放大和縮小:
<div class="flex ...">
<div class="flex-auto ...">
<!-- Will grow and shrink as needed taking initial size into account -->
</div>
<div class="flex-auto ...">
<!-- Will grow and shrink as needed taking initial size into account -->
</div>
<div class="flex-auto ...">
<!-- Will grow and shrink as needed taking initial size into account -->
</div>
</div>
使用 ?flex-none
? 來阻止一個(gè) flex 項(xiàng)目的放大和縮?。?/p>
<div class="flex ...">
<div class="flex-1 ...">
<!-- Will grow and shrink as needed -->
</div>
<div class="flex-none ...">
<!-- Will not grow or shrink -->
</div>
<div class="flex-1 ...">
<!-- Will grow and shrink as needed -->
</div>
</div>
要控制 flex 項(xiàng)目在特定斷點(diǎn)處的放大和縮小方式,可在任何現(xiàn)有的功能類產(chǎn)添加 ?{screen}:
? 前綴。例如,使用 ?md:flex-1
? 僅在中等尺寸及以上的屏幕應(yīng)用 ?flex-1
? 功能。
<div class="flex ...">
<!-- ... -->
<div class="flex-none md:flex-1 ...">
Responsive flex item
</div>
<!-- ... -->
</div>
關(guān)于 Tailwind 的響應(yīng)式設(shè)計(jì)功能的更多信息,請(qǐng)查看 響應(yīng)式設(shè)計(jì) 文檔。
默認(rèn)情況下,Tailwind 提供了四個(gè) ?flex
?實(shí)用程序。您可以通過編輯 Tailwind 配置的 ?theme.flex
? 部分來更改、添加或刪除這些內(nèi)容。
// tailwind.config.js
module.exports = {
theme: {
flex: {
'1': '1 1 0%',
auto: '1 1 auto',
initial: '0 1 auto',
inherit: 'inherit',
none: 'none',
'2': '2 2 0%',
}
}
}
默認(rèn)情況下, 針對(duì) flex 功能類,只生成 responsive 變體。
您可以通過修改您的 ?tailwind.config.js
? 文件中的 ?variants
?部分中的 ?flex
?屬性來控制為 flex 功能生成哪些變體。
例如,這個(gè)配置也將生成 hover and focus 變體:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
flex: ['hover', 'focus'],
}
}
}
如果您不打算在您的項(xiàng)目中使用 flex 功能,您可以通過在配置文件的 ?corePlugins
?部分將 ?flex
?屬性設(shè)置為 ?false
?來完全禁用它們:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
flex: 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)系方式:
更多建議: