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