This div uses a background image with
bg-cover
and
bg-center
.
It also has
h-96
to ensure the background is visible and has space.
bg-cover
makes the image cover the entire area, potentially cropping.
bg-center
positions the image from its center.
Another example with
bg-cover
,
bg-center
, and explicit
bg-no-repeat
.
bg-no-repeat
is good practice, though often implied by
bg-cover
's behavior of scaling to fill.
bg-[url('...')]
.
h-64
,
min-h-screen
, or ensure content gives it height).
bg-cover
to ensure the image fills the container without distortion (it may crop).
bg-center
(or
bg-top
,
bg-left
, etc.) to control image positioning.
bg-no-repeat
if you don't want tiling, especially if not using
bg-cover
.