Chevron left

Content

Images

Theme

Themes/hound/logo.svg

Hound

Framework

Tailwind CSS logo

Tailwind CSS

Images

Responsive images

Display images that scale proportionally relative to browser widths.

<img src="#" class="max-w-full h-auto">
<%= image_tag "...", class: "max-w-full", alt:"..." %>
%img.max-w-full{:alt => "...", :src => "..."}

Images - Object Fit

Object Cover

Resize an element's content to cover it's container using .object-cover

dog
<div class="bg-slate-50...">
  <img src="#" class="object-cover h-48 w-96">
</div>
<div class="bg-slate-50...">
  <%= image_tag "#", class: "object-cover h-48 w-96" %>
</div>
.bg-slate-50
  image_tag "#", class: "object-cover h-48 w-96"

Images - Object Fit

Object Contain

Resize an element’s content to stay contained within its container using .object-contain.

fruit
<div class="bg-slate-50...">
  <img src="#" class="object-contain h-48 w-96">
</div>
<div class="bg-slate-50...">
  <%= image_tag "#", class: "object-contain h-48 w-96" %>
</div>
.bg-slate-50
  image_tag "#", class: "object-contain h-48 w-96"

Images - Object Fit

Object Fill

Stretch an element's content to fit its container .object-fill.

dog
<div class="bg-slate-50...">
  <img src="#" class="object-fill h-48 w-96">
</div>
<div class="bg-slate-500...">
  <%= image_tag "#", class: "object-fill h-48 w-96" %>
</div>
.bg-slate-50
  image_tag "#", class: "object-fill h-48 w-96"

Images - Object Fit

Object Scale Down

Display an element’s content at its original size but scale it down to fit its container if necessary using .object-scale-down.

fruit
<div class="bg-slate-50...">
  <img src="#" class="object-scale-down h-48 w-96">
</div>
<div class="bg-slate-50...">
  <%= image_tag "#", class: "object-scale-down h-48 w-96" %>
</div>
.bg-slate-50
  image_tag "#", class: "object-scale-down h-48 w-96"