Skip to main content

Aspect Ratio & Object Fit

Utility classes for controlling the aspect ratio of elements and how content fits within them.

Aspect Ratio

ClassRatioCommon Use
.square1:1Profile photos, thumbnails
.widescreen16:9Videos, hero images
.portrait9:16Vertical/mobile video, stories
.cinemascope2.35:1Ultra-wide cinematic content

Usage

<div class="widescreen">
<img src="hero.jpg" class="object-cover" />
</div>
note

The .portrait class is scoped to exclude the WordPress media modal (.media-modal-content) to avoid interfering with the media library UI.

Object Fit

Control how an element's content (typically images or video) fills its container.

ClassDescription
.object-containScales to fit within the container, preserving aspect ratio (may leave empty space)
.object-coverScales to fill the container, preserving aspect ratio (may crop)
.object-fillStretches to fill the container exactly (may distort)
.object-noneContent is not resized
.object-scale-downScales down like contain if needed, but never scales up

Example: Cover Image

<div class="widescreen">
<img src="photo.jpg" class="object-cover w-full" />
</div>