W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
用來設(shè)置元素高度的功能類
Class
|
Properties
|
---|---|
h-0 | height: 0px; |
h-px | height: 1px; |
h-0.5 | height: 0.125rem; |
h-1 | height: 0.25rem; |
h-1.5 | height: 0.375rem; |
h-2 | height: 0.5rem; |
h-2.5 | height: 0.625rem; |
h-3 | height: 0.75rem; |
h-3.5 | height: 0.875rem; |
h-4 | height: 1rem; |
h-5 | height: 1.25rem; |
h-6 | height: 1.5rem; |
h-7 | height: 1.75rem; |
h-8 | height: 2rem; |
h-9 | height: 2.25rem; |
h-10 | height: 2.5rem; |
h-11 | height: 2.75rem; |
h-12 | height: 3rem; |
h-14 | height: 3.5rem; |
h-16 | height: 4rem; |
h-20 | height: 5rem; |
h-24 | height: 6rem; |
h-28 | height: 7rem; |
h-32 | height: 8rem; |
h-36 | height: 9rem; |
h-40 | height: 10rem; |
h-44 | height: 11rem; |
h-48 | height: 12rem; |
h-52 | height: 13rem; |
h-56 | height: 14rem; |
h-60 | height: 15rem; |
h-64 | height: 16rem; |
h-72 | height: 18rem; |
h-80 | height: 20rem; |
h-96 | height: 24rem; |
h-auto | height: auto; |
h-1/2 | height: 50%; |
h-1/3 | height: 33.333333%; |
h-2/3 | height: 66.666667%; |
h-1/4 | height: 25%; |
h-2/4 | height: 50%; |
h-3/4 | height: 75%; |
h-1/5 | height: 20%; |
h-2/5 | height: 40%; |
h-3/5 | height: 60%; |
h-4/5 | height: 80%; |
h-1/6 | height: 16.666667%; |
h-2/6 | height: 33.333333%; |
h-3/6 | height: 50%; |
h-4/6 | height: 66.666667%; |
h-5/6 | height: 83.333333%; |
h-full | height: 100%; |
h-screen | height: 100vh; |
使用 ?h-auto
? 讓瀏覽器決定元素的高度。
<div class="h-auto ...">h-auto</div>
使用 ?h-screen
? 使一個(gè)元素跨越整個(gè)視口的高度。
<div class="h-screen p-6 ...">h-screen</div>
使用 ?h-{number}
? 或 ?h-px
? 將元素設(shè)置為固定高度。
<div>
<div class="h-8 ..."></div>
<div class="h-12 ..."></div>
<div class="h-16 ..."></div>
<div class="h-24 ..."></div>
</div>
使用 ?h-full
? 將一個(gè)元素的高度設(shè)置為其父元素的 100%,只要父元素有一個(gè)定義的高度。
<div class="h-48">
<div class="h-full ...">h-full</div>
</div>
要在特定的斷點(diǎn)處控制元素的高度,可以在任何現(xiàn)有的高度功能類前添加 ?{screen}:
? 前綴。例如,將 ?md:h-full
? 類添加到一個(gè)元素中,就可以在中等及以上尺寸屏幕的情況下應(yīng)用用 ?h-full
? 功能類。
<div class="h-8 md:h-full"></div>
關(guān)于 Tailwind 的響應(yīng)式設(shè)計(jì)功能的更多信息,請查看 響應(yīng)式設(shè)計(jì) 文檔。
默認(rèn)情況下,Tailwind 的高度比例是 默認(rèn)間距比例 以及一些特定高度的附加值的組合。
您可以在您的 ?tailwind.config.js
? 文件中的 ?theme.spacing
? 部分一次性自定義 padding、margin、width 和 height 的間距比例。
// tailwind.config.js
module.exports = {
theme: {
spacing: {
sm: '8px',
md: '16px',
lg: '24px',
xl: '48px',
}
}
}
要單獨(dú)定制高度,請使用您的 ?tailwind.config.js
? 文件中的 ?theme.height
? 部分。
// tailwind.config.js
module.exports = {
theme: {
height: {
sm: '8px',
md: '16px',
lg: '24px',
xl: '48px',
}
}
}
默認(rèn)情況下, 針對 height 功能類,只生成 responsive 變體。
您可以通過修改您的 ?tailwind.config.js
? 文件中的 ?variants
?部分中的 ?height
?屬性來控制為 height 功能生成哪些變體。
例如,這個(gè)配置也將生成 hover and focus 變體:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
height: ['hover', 'focus'],
}
}
}
如果您不打算在您的項(xiàng)目中使用 height 功能,您可以通過在配置文件的 ?corePlugins
?部分將 ?height
?屬性設(shè)置為 ?false
?來完全禁用它們:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
height: 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)系方式:
更多建議: