Background Repeat

    Repeat

    Use to repeat the background image both vertically and horizontally.

    Use .bg-no-repeat when you don’t want to repeat the background image.

    Background Repeat - 图2

    1. <div class="bg-no-repeat bg-center ..." style="background-image: url(...)"></div>

    Repeat Horizontally

    Use .bg-repeat-x to repeat the background image only horizontally.

    Use .bg-repeat-y to repeat the background image only vertically.

    1. <div class="bg-repeat-y bg-center ..." style="background-image: url(...)"></div>

    Responsive

    To control the repetition of an element’s background image at a specific breakpoint, add a {screen}: prefix to any existing background repeat utility. For example, adding the class to an element would apply the bg-repeat-x utility at medium screen sizes and above.

    For more information about Tailwind’s responsive design features, check out the documentation.

    Background Repeat - 图5

    all

    sm

    Background Repeat - 图7

    lg

    Background Repeat - 图9

    xl

    By default, only responsive variants are generated for background repeat utilities.

    You can control which variants are generated for the background repeat utilities by modifying the backgroundRepeat property in the variants section of your tailwind.config.js file.

    For example, this config will also generate hover and focus variants:

    1. module.exports = {
    2. // ...
    3. - backgroundRepeat: ['responsive'],
    4. + backgroundRepeat: ['responsive', 'hover', 'focus'],
    5. }

    Disabling


      Background Size →