Koala
TTCTheo's Typesafe Cult
•Created by Koala on 5/20/2024 in #questions
Sizing to fit parent container, while respecting css "aspect-ratio"
I've been struggling with this for 2 hours so hopefully someone can help me out.
I have a div that I need a set aspect ratio, and am using the CSS "aspect-ratio" attribute for this. This div (white) needs to scale to fit the parent container (red), while maintaining aspect ratio.
I need my container to be scaled, not just what is shown in the viewport (i.e. no overflow-hidden). I also need this to be pure CSS, as this is in a NextJS server component.
current code:
6 replies