Learn how to style images with Tailwind's utility classes.
Use w-full h-auto to
make an image scale with its parent container — the Tailwind
equivalent of Bootstrap's
.img-fluid.
class="w-full h-auto"
Control how an image fills its container with
object-{fit}. Always
pair with fixed dimensions.
Crops to fill. Aspect ratio kept.
Fits inside. May show gaps.
Stretches to fill. May distort.
Text wraps around the image because the image is floated to the left.
Text wraps around the image because the image is floated to the right.
class="block mx-auto"
rounded
rounded-xl
rounded-full (circle)
rounded-full (pill)
Use relative on the
container and
absolute inset-0 on the
overlay:
Dark Overlay
Gradient Overlay