Zazz Design Framework
Reference

Object Fit

Utilities for controlling how images and videos fit their container.

Class reference

ClassPropertyBehavior
object-containobject-fit: containScale to fit while maintaining aspect ratio. May leave empty space.
object-coverobject-fit: coverScale to fill the container. May crop.
object-fillobject-fit: fillStretch to fill. May distort.
object-noneobject-fit: noneKeep original size. May overflow.
object-scale-downobject-fit: scale-downUse contain or none, whichever is smaller.

Examples

Cover: hero images and product photography

<div class="aspect-widescreen">
  <img class="w-full h-full object-cover" src="hero.jpg" alt="" />
</div>

Contain: logos and graphics that shouldn't crop

<div class="aspect-square" style="background: var(--muted)">
  <img class="w-full h-full object-contain" src="logo.svg" alt="" />
</div>

Scale-down: thumbnails that should never upscale

<div class="aspect-square">
  <img class="w-full h-full object-scale-down" src="thumb.png" alt="" />
</div>

Pairing with aspect-ratio

object-fit only matters when the container has a fixed size (or aspect ratio) different from the media's natural aspect. Pair with aspect-ratio utilities for cleanly cropped grids of images.

Object position

Zazz doesn't ship object-position-* utilities. Set directly when needed:

.hero-img {
  object-fit: cover;
  object-position: 50% 30%; /* crop slightly above center */
}

On this page