Tailwind CSS 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:
<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.
<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
Class | Properties |
---|---|
object-bottom | object-position: bottom; |
object-center | object-position: center; |
object-left | object-position: left; |
object-left-bottom | object-position: left bottom; |
object-left-top | object-position: left top; |
object-right | object-position: right; |
object-right-bottom | object-position: right bottom; |
object-right-top | object-position: right top; |
object-top | object-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.