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.
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
Build modern projects using Bootstrap 5 and Contrast
Trying to create components and pages for a web app or website from
scratch while maintaining a modern User interface can be very tedious.
This is why we created Contrast, to help drastically reduce the amount of time we spend doing that.
so we can focus on building some other aspects of the project.
Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants.
Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for
building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.