Tailwind CSS Background Position
The bg-{position} utility class in Tailwind CSS allows you to control the positioning of background images applied to elements. With Tailwind background position class, you can easily adjust the placement of background images to achieve the desired visual effect
Tailwind Background Position
The bg-{position}
utility class in Tailwind CSS allows you to control the positioning of background images applied to elements. With Tailwind background position class, you can easily adjust the placement of background images to achieve the desired visual effect.
Applying Tailwind Background Position
To apply a specific tailwind background position to an element, you can use the bg-{position}
utility class, where {position}
represents the desired background position. Here are some common values you can use:
bg-top
: The background image is positioned at the top of the element.bg-center
: The background image is positioned at the center of the element.bg-bottom
: The background image is positioned at the bottom of the element.bg-left
: The background image is positioned at the left side of the element.bg-right
: The background image is positioned at the right side of the element. Here's an example:
<div class="bg-top-left"></div><div class="bg-top"></div><div class="bg-top-right"></div>
Preview
Responsive Tailwind Background Position
Tailwind CSS allows you to apply background position classes responsively at different breakpoints. To use responsive tailwind background position classes, you can append the breakpoint prefix to the utility class. For example, md:bg-right
sets the background position to the right starting from the medium breakpoint and above.
<div class="bg-left md:bg-right"> This element has a background image that is positioned at the left by default, but starting from the medium breakpoint and above, it changes to the right side.</div>
In the above example, the tailwind background position of the <div>
element is set to the left by default (bg-left)
, but starting from the medium breakpoint and above, it changes to the right side (md:bg-right)
.
Tailwind Background Position Class Table
Class | Properties |
---|---|
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; |
Windframe Tailwind blocks
Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs