背景
用于控制元素背景图像重复的工具类。
Class | Styles |
---|---|
bg-repeat | background-repeat: repeat; |
bg-repeat-x | background-repeat: repeat-x; |
bg-repeat-y | background-repeat: repeat-y; |
bg-repeat-space | background-repeat: space; |
bg-repeat-round | background-repeat: round; |
bg-no-repeat | background-repeat: no-repeat; |
使用 bg-repeat
工具类使背景图像在垂直和水平方向上重复:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat ..."></div>
使用 bg-repeat-x
工具类仅使背景图像在水平方向上重复:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat-x ..."></div>
使用 bg-repeat-y
工具类仅使背景图像在垂直方向上重复:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat-y ..."></div>
使用 bg-repeat-space
工具类在不剪切的情况下重复背景图像:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat-space ..."></div>
使用 bg-repeat-round
工具类在不剪切的情况下重复背景图像,并在需要的时候拉伸以避免间隙:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat-round ..."></div>
使用 bg-no-repeat
工具类防止背景图像重复:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-no-repeat ..."></div>
Prefix a background-repeat
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="bg-repeat md:bg-repeat-x ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.