媒體與 SVG

物件位置object-position

Setting the alignment of the selected replaced element within the element's box.

Overview

ClassDeclarations
object-topobject-position: top;
object-bottomobject-position: bottom;
object-leftobject-position: left;
object-rightobject-position: right;
object-centerobject-position: center;
object-position:<position>object-position: <position>;

Examples

Center cropped media

Use object-center to keep the center of an image visible when object-cover crops the edges.

<img class="aspect-ratio:16/9 object-cover object-center" src="/images/photo.jpg" alt="Photo">
Generated CSS
@layer utilities {    .object-center {        object-position: center    }}

Pin the top of an image

Use object-top for portraits or screenshots where the important content is near the top.

<img class="aspect-ratio:4/3 object-cover object-top" src="/images/portrait.jpg" alt="Portrait">

Use precise positions

Use object-position:*|* when the focal point needs a custom x and y position.

<img class="object-cover object-position:50%|25%" src="/images/scene.jpg" alt="Scene">

Apply conditionally

Apply styles based on different states using selectors and conditional queries.

<img class="object-center:hover object-top@sm object-position:50%|50%@print" src="/images/photo.jpg" alt="">

  • Master UI


© 2026 Aoyue Design LLC.MIT License
Trademark Policy