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 box model.
Tailwind 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
This element has a background image that originates from the padding box.
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
Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs