Layout
Utilities for controlling how a replaced element's content should be positioned within its container.
Class | Styles |
---|---|
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; |
object-(<custom-property>) | object-position: var(<custom-property>); |
object-[<value>] | object-position: <value>; |
Use utilities like object-left
and object-right-bottom
to specify how a replaced element's content should be positioned within its container:
Hover over examples to see the full image
object-left-top
object-top
object-right-top
object-left
object-center
object-right
object-left-bottom
object-bottom
object-right-bottom
<img class="size-24 object-left-top ..." src="/img/mountains.jpg" /><img class="size-24 object-top ..." src="/img/mountains.jpg" /><img class="size-24 object-right-top ..." src="/img/mountains.jpg" /><img class="size-24 object-left ..." src="/img/mountains.jpg" /><img class="size-24 object-center ..." src="/img/mountains.jpg" /><img class="size-24 object-right ..." src="/img/mountains.jpg" /><img class="size-24 object-left-bottom ..." src="/img/mountains.jpg" /><img class="size-24 object-bottom ..." src="/img/mountains.jpg" /><img class="size-24 object-right-bottom ..." src="/img/mountains.jpg" />
Use the object-[<value>]
syntax to set the object position based on a completely custom value:
<img class="object-[25%_75%] ..." src="/img/mountains.jpg" />
For CSS variables, you can also use the object-(<custom-property>)
syntax:
<img class="object-(--my-object) ..." src="/img/mountains.jpg" />
This is just a shorthand for object-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix an object-position
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<img class="object-center md:object-top ..." src="/img/mountains.jpg" />
Learn more about using variants in the variants documentation.