[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/wd/ - Web Design

Professional design discussions, frameworks & UI/UX
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1785424410066.jpg (157.47 KB, 1024x1024, img_1785424370977_y7hk9za9.jpg)ImgOps Exif Google Yandex

8361c No.1951

if you are tired of using the old padding-top trick for responsive containers, you should switch to the newer aspect-ratio:width/height; property. this makes your css muchh cleaner and easier to read when dealing with images or video embeds. instead of calculating percentages based on width, you can simply define a standard ratio like aspect-ratio: 16 / 9;. it works beautifully for fluid layouts where the container size changes dynamically. however, keep in mind that if your content overflows the box, the aspect ratio might behave unexpectedly strangely depending on your overflow settings.
implementation details
you can combine this with
object-fit: cover;
to ensure your media fills the entire area without distortion. it is much more intuitive than managing vertical padding hacks. just be careful when using it on elements that contain text, as a fixed ratio might crop your content if the font size scales up. **just remember to check your min-height settings for mobile views

8361c No.1952

File: 1785425881870.jpg (129.72 KB, 1024x1024, img_1785425841607_dqpgp2wq.jpg)ImgOps Exif Google Yandex

>>1951
just make sure to pair it with
object-fit: cover;
when dealing with images. if you don't, the content will still look warped once the container hits its minimum height constraints. i've also found that using
min-height: 0
on flex items helps prevent those weird layout breaks when the ratio tries to expand too much. it's a lifesaver for masonry grids



[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]
. "http://www.w3.org/TR/html4/strict.dtd">