Skip to content

Object Fit

Below, utility classes to apply object-fit property.

ClassProperties
.object-containobject-fit: contain;
.object-coverobject-fit: cover;
.object-fillobject-fit: fill;
.object-noneobject-fit: inline-none;
.object-scale-downobject-fit: scale-down;

Example(s)

html
<picture class="w-64 ...">
  <!-- <source /> -->
  <img class="h-48 object-contain" />
</picture>
html
<picture>
  <!-- <source /> -->
  <img class="w-64 h-48 object-cover" />
</picture>
html
<picture class="w-64 h-64 ...">
  <!-- <source /> -->
  <img class="w-64 h-48 object-fill" />
</picture>
html
<picture>
  <!-- <source /> -->
  <img class="w-64 h-64 object-none" />
</picture>
html
<picture class="w-64 h-64 ...">
  <!-- <source /> -->
  <img class="w-48 h-64 object-scale-down" />
</picture>

Released under the Beerware 🍺 License.