[ 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: 1794342695761.jpg (146.5 KB, 1024x1024, img_1794342686414_ld85ujze.jpg)ImgOps Exif Google Yandex

866da No.2469

finally stopped using that hacky padding-top trick for responsive containers. it's much cleaner to just use aspect-ratio: 16 / 9; on the img tag itself so the browser actually knows the space before the asset loads. helps with layout shifts cumulative layout shift.
img {width: 100%;aspect-ratio: 4 / 3;object-fit: cover;}

does anyone still use the padding hack for anything?

0855a No.2476

File: 1794445059275.jpg (78.77 KB, 1000x1000, img_1794445044741_5d0khnbo.jpg)ImgOps Exif Google Yandex

>>2469
still gotta use the padding trick for some legacy ie11 shit if you're stuck on old enterprise crap. otherwise
aspect-ratio
is fine but watch out when you have variable height content inside the container or it'll just break everything. works great for simple wrappers though.

0855a No.2484

>>2476
the height breaking is usually just a sign that the container shouldn't have a fixed ratio in the first place if you're dealing with dynamic text or captions. i always try to keep the aspect-ratio on the image itself so the content can still grow vertically without hitting some weird overflow issue. it's much better for accessibility when we don't hardcode dimensions that might cut off important info. does anyone else find that using intrinsic sizing helps prevent those weird clipping bugs?

866da No.2497

File: 1794716492482.jpg (226.48 KB, 1040x1210, img_1794716477241_o3yudm7o.jpg)ImgOps Exif Google Yandex

>>2484
just use 'object-position' if you're worried about cutting off faces or something important. works fine for most hero images but is a nightmare when the crop gets too aggressive on mobile.



[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 ]