Performance: Background repeat control
Controls how background images repeat affects paint and layout performance during page load and resizing.
Jump into concepts and practice - no test required
<div class="bg-[url('/image.png')] bg-no-repeat bg-center bg-cover"><div class="bg-[url('/image.png')] bg-repeat">| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| bg-repeat with large image | Low | 0 | High (many tiles painted) | [X] Bad |
| bg-no-repeat with optimized image | Low | 0 | Low (single paint) | [OK] Good |
bg-repeatbg-repeat makes the background image repeat both horizontally and vertically by default.bg-no-repeat stops repetition, bg-repeat-x repeats only horizontally, and bg-repeat-y repeats only vertically.bg-no-repeat stops the background image from repeating.bg-repeat repeats, bg-repeat-all and bg-repeat-none are not valid Tailwind classes.<div class="bg-repeat-x bg-[url('/pattern.png')] h-40 w-40"></div>bg-repeat-x classbg-repeat-x is used, vertical repetition is disabled.bg-repeat-x. What is the fix?bg-repeat-x repeats horizontally, but vertical repeat is needed.bg-repeat-y repeats the background image vertically only.bg-repeat-x repeats the background image horizontally.background-size to 50% width means the image covers half the container width, so it repeats twice horizontally.