How?
Create a two empty elements stacked together with Position and Top/Bottom/Left/Right utilities.
<div class="relative">
<!-- Background Layer -->
<div class="absolute top-0 left-0">
<img class="..." src="...">
</div>
<!-- Foreground Layer -->
<div class="..."></div>
</div>
Set up Background Layer
image to spread across the screen with Height and Width utilities.
Set focus on the center of the image with Object Fit and set the alignment to top (optional) with Object Position utilities.
<div class="relative">
<!-- Background Layer -->
<div class="absolute top-0 left-0">
<img class="h-screen w-screen ... object-cover object-top" src="...">
</div>
<!-- Foreground Layer -->
<div class="..."></div>
</div>
Use Overflow utilities to prevent any element overflowing the screen edge to hide the scrollbars.
Center for the Foreground Layer
with Flex, Justify-Content and Align Items utilities.
<div class="relative ... h-screen ... flex justify-center items-center ... overflow-hidden">
<!-- Background Layer -->
<div class="absolute top-0 left-0">
<img class="h-screen w-screen ... object-cover object-top" src="...">
</div>
<!-- Foreground Layer -->
<div class="..."></div>
</div>
At Foreground Layer
, set the element to bg-transparent
with Background Color and add blur effect with Backdrop Blur utilities. Final touch up to add a dreamy shadow with Box Shadow utilities.
<div class="relative ... h-screen ... flex justify-center items-center ... overflow-hidden">
<!-- Background Layer -->
<div class="absolute top-0 left-0">
<img class="h-screen w-screen ... object-cover object-top" src="...">
</div>
<!-- Foreground Layer -->
<div class="h-72 w-72 ... bg-transparent ... backdrop-filter blur-6 ... shadow-dreamy-md"></div>
</div>
Visit Yogurt Playground to have experience of the Yogurt CSS with fullness.
Enjoy then!