Backgrounds
Utilities for controlling the position of an element's background image.
| Class | Styles | 
|---|---|
| bg-bottom | background-position: bottom; | 
| bg-center | background-position: center; | 
| bg-left | background-position: left; | 
| bg-left-bottom | background-position: left bottom; | 
| bg-left-top | background-position: left top; | 
| bg-right | background-position: right; | 
| bg-right-bottom | background-position: right bottom; | 
| bg-right-top | background-position: right top; | 
| bg-top | background-position: top; | 
| bg-(<custom-property>) | background-position: var(<custom-property>); | 
| bg-[<value>] | background-position: <value>; | 
Use utilities like bg-center, bg-right, and bg-left-top to control the position of an element's background image:
Hover over these examples to see the full image
bg-left-top
bg-top
bg-right-top
bg-left
bg-center
bg-right
bg-left-bottom
bg-bottom
bg-right-bottom
<div class="bg-[url(/img/mountains.jpg)] bg-left-top"></div><div class="bg-[url(/img/mountains.jpg)] bg-top"></div><div class="bg-[url(/img/mountains.jpg)] bg-right-top"></div><div class="bg-[url(/img/mountains.jpg)] bg-left"></div><div class="bg-[url(/img/mountains.jpg)] bg-center"></div><div class="bg-[url(/img/mountains.jpg)] bg-right"></div><div class="bg-[url(/img/mountains.jpg)] bg-left-bottom"></div><div class="bg-[url(/img/mountains.jpg)] bg-bottom"></div><div class="bg-[url(/img/mountains.jpg)] bg-right-bottom"></div>Use the bg-[<value>] syntax to set the background position based on a completely custom value:
<div class="bg-[center_top_1rem] ...">  <!-- ... --></div>For CSS variables, you can also use the bg-(<custom-property>) syntax:
<div class="bg-(--my-bg-position) ...">  <!-- ... --></div>This is just a shorthand for bg-[var(<custom-property>)] that adds the var() function for you automatically.
Prefix a background-position utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:
<div class="bg-center md:bg-top ...">  <!-- ... --></div>Learn more about using variants in the variants documentation.