控制元素 (Element) 背景圖片的重覆顯示
<div class="bg-repeat ..." style="background-image: url(...)"></div>
<div class="bg-no-repeat bg-center ..." style="background-image: url(...)"></div>
<div class="bg-repeat-x bg-center ..." style="background-image: url(...)"></div>
<div class="bg-repeat-y bg-center ..." style="background-image: url(...)"></div>
如要讓元素背景圖片的重覆顯示有響應式效果,可在現有背景重覆顯示功能前加上前綴詞 {screen}:
。例如:中型或以上的螢幕尺寸使用 md:bg-repeat-x
以套用 bg-repeat-x
功能。
<div class="bg-repeat md:bg-repeat-x ..."></div>
更多有關 Tailwind 響應式設計功能的資訊,可參考 響應式設計 文件。
默認情況下, 只有 響應式 的 background repeat 變化模式 (variants) 會產生。
在 tailwind.config.js
的 variants
區塊中變更 backgroundRepeat
屬性來決定有哪些變化模式會生成。
舉個例子來說,這個設定將會生成 響應式 和 hover 的變化模式。
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
+ backgroundRepeat: ['responsive', 'hover'],
}
}
}
如果你不打算在專案中使用 background repeat 功能,可以在你的設定檔裡的 corePlugins
屬性中將 backgroundRepeat
設定為 false
來停用功能:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ backgroundRepeat: false,
}
}