Last updated: 19 May 2024

Tailwind CSS Object Position

The object-{position} utility class in Tailwind CSS allows you to control the positioning of objects within their containing elements.


Tailwind object Position

The object-{position} utility class in Tailwind CSS allows you to control the positioning of objects within their containing elements. With Tailwind's object-position class, you can easily adjust the horizontal and vertical position of images, videos, and other objects.

Applying Object Position

To apply a specific object position to an element, you can use the object-{position} utility class, where {position} represents the desired object position. Here are some common values you can use:

  • object-bottom: Positions the object at the bottom of its containing element.
  • object-center: Positions the object at the center both horizontally and vertically within its containing element.
  • object-left: Positions the object at the left edge of its containing element.
  • object-left-bottom: Positions the object at the left-bottom corner of its containing element.
  • object-left-top: Positions the object at the left-top corner of its containing element.
  • object-right: Positions the object at the right edge of its containing element.
  • object-right-bottom: Positions the object at the right-bottom corner of its containing element.
  • object-right-top: Positions the object at the right-top corner of its containing element.
  • object-top: Positions the object at the top of its containing element. Here's an example:
html
<img src="image.jpg" class="object-top-left" alt="Object positioned at the top left" />
<img src="image.jpg" class="object-top" alt="Object positioned at the top" />
<img src="image.jpg" class="object-right-top" alt="Object positioned at the top right" />

Preview

Responsive Object Position

Tailwind CSS allows you to apply object position classes responsively at different breakpoints. To use responsive object position classes, you can append the breakpoint prefix to the utility class. For example, md:object-right-bottom positions the object at the right-bottom corner starting from the medium breakpoint and above.

html
<div class="object-center md:object-right-bottom">
<!-- Content here -->
</div>

In the above example, the object position of the <div> element is set to center by default (object-center), but starting from the medium breakpoint and above, it changes to the right-bottom corner (md:object-right-bottom).

Tailwind CSS Object Position

ClassProperties
object-bottomobject-position: bottom;
object-centerobject-position: center;
object-leftobject-position: left;
object-left-bottomobject-position: left bottom;
object-left-topobject-position: left top;
object-rightobject-position: right;
object-right-bottomobject-position: right bottom;
object-right-top object-position: right top;
object-top object-position: top;

Windframe Tailwind blocks

Pricing

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