Last updated: 4 May 2024

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:
html
<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.

html
<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

ClassProperties
bg-bottombackground-position: bottom;
bg-centerbackground-position: center;
bg-leftbackground-position: left;
bg-left-bottombackground-position: left bottom;
bg-left-topbackground-position: left top;
bg-rightbackground-position: right;
bg-right-bottombackground-position: right bottom;
bg-right-topbackground-position: right top;
bg-topbackground-position: top;

Windframe Tailwind blocks

Timeline

Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs

Start building stunning tailwind UIs! 

Build from scratch or select prebuilt tailwind templates