Closed
Description
Modern time we have css grids,
and grids allows to create same aspect ratio cells using different methods and without wrapping image with aspect ratio div.
i.e. https://codepen.io/istarkov/pen/RwGXVYp
<div class="relative">
<div id="aspect-ratio-setter" style="width: 25%" class="bg-red-200">
<div style="padding-top: 57%;"></div>
</div>
<div
class="grid gap-4 absolute inset-0"
style="grid-template-columns: repeat(200, 25%)"
>
<img class="block w-full h-full" src="https://via.placeholder.com/300/09f/fff.png"/>
<img class="block w-full h-full" src="https://via.placeholder.com/300/09f/fff.png"/>
</div>
</div>
See codepen images has ratio I set in #aspect-ratio-setter
Solution above allows to create carousels, image boards, etc with 2x less (or even 3x if we calc pseudo) elements.
And above is not the only solution with grids I know and sometimes use others.
Can we not show this diagnostic warning if Cumulative Layout Shift
is equal to zero?
PS: I cant set width and height attrs on image element as we use responsive aspect ratio.