Tailwind CSS Background Origin
The bg-{origin}
utility class in Tailwind CSS allows you to control the position origin of background images applied to elements. With Tailwind background origin class, you can easily adjust where the background image originates within the element's box model.
Applying Tailwind Background Origin
To apply a specific tailwind background origin to an element, you can use the bg-{origin}
utility class, where {origin}
represents the desired background origin. Here are some common values you can use:
bg-origin-border
: The background image originates from the border box.bg-origin-padding
: The background image originates from the padding box.bg-origin-content
: The background image originates from the content box. Here's an example:
<div class="bg-origin-padding"> This element has a background image that originates from the padding box.</div>
Preview
Responsive Tailwind Background Origin
Tailwind CSS allows you to apply background origin classes responsively at different breakpoints. To use responsive tailwind background origin classes, you can append the breakpoint prefix to the utility class. For example, md:bg-origin-content
sets the background origin to the content box starting from the medium breakpoint and above.
<div class="bg-origin-border md:bg-origin-content"> This element has a background image that originates from the border box by default, but starting from the medium breakpoint and above, it changes to originate from the content box.</div>
In the above example, the tailwind background origin of the <div>
element is set to the border box by default (bg-origin-border)
, but starting from the medium breakpoint and above, it changes to originate from the content box (md:bg-origin-content)
.
Tailwind Background Origin Class Table
Class | Properties |
---|---|
bg-origin-border | background-origin: border-box; |
bg-origin-padding | background-origin: padding-box; |
bg-origin-content | background-origin: content-box; |
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.