將背景色相濾鏡套用在元素的功能
Use the backdrop-hue-rotate-{amount}
utilities alongside the backdrop-filter
utility to rotate the hue of an element’s backdrop.
<div class="backdrop-filter backdrop-hue-rotate-15 ...">
<!-- ... -->
</div>
如要讓元素的背景色相旋轉有響應式效果,可在現有背景色相旋轉功能前加上前綴詞 {screen}:
。例如:中型或以上的螢幕尺寸使用 md:backdrop-hue-rotate-60
以套用 backdrop-hue-rotate-60
功能。
<div class="backdrop-filter backdrop-hue-rotate-15 md:backdrop-hue-rotate-60 ...">
<!-- ... -->
</div>
更多有關 Tailwind 響應式設計功能的資訊,可參考 響應式設計 文件。
你可以在tailwind.config.js
的theme
區塊中,使用backdropHueRotate
這個 key 來客製化你要的backdrop-hue-rotate
效果。
// tailwind.config.js
module.exports = {
theme: {
+ extend: {
+ backdropHueRotate: {
+ '-270': '-270deg',
+ 270: '270deg',
+ }
+ }
}
}
更多有關客製化預設主題的資訊,可參考主題客製化文件。
默認情況下, 只有 響應式 的 backdrop hue-rotate 變化模式 (variants) 會產生。
在 tailwind.config.js
的 variants
區塊中變更 backdropHueRotate
屬性來決定有哪些變化模式會生成。
舉個例子來說,這個設定將會生成 響應式 和 hover 的變化模式。
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
+ backdropHueRotate: ['responsive', 'hover'],
}
}
}
如果你不打算在專案中使用 backdrop hue-rotate 功能,可以在你的設定檔裡的 corePlugins
屬性中將 backdropHueRotate
設定為 false
來停用功能:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ backdropHueRotate: false,
}
}