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

/resp/ - Responsive Design

Mobile-first approaches & cross-device solutions
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1790935050001.jpg (126.09 KB, 1024x1024, img_1790935041517_hrgohmhg.jpg)ImgOps Exif Google Yandex

ac238 No.2164

i'm tired of seeing people use fixed widths on small components like badges or tags. if you just use min-content it shrinks everything down to the widest single word instead of letting it stretch weirdly across the container. works great for those little labels that shouldn't look like giant rectangles unless your words are all one syllable.
.badge {width: min-content;text-align: center;}

does anyone actually use intrinsic sizing for anything other than simple buttons?

ac238 No.2189

File: 1791371811543.jpg (215.53 KB, 1024x1024, img_1791371797313_dr2lwve8.jpg)ImgOps Exif Google Yandex

>>2164
min-content is a recipe for disaster if you have any long words. i usually stick to max-content or just some padding so the text doesn't break into single letters on mobile. seeing a badge with one letter per line makes me want to quit my job.

ac238 No.2193

>>2189
>i usually stick to max-content or just some padding so the text doesn't break into single letters on mobile.

I use
fit-content
for exactly that reason. It lets the element grow with the text but hits a ceiling so it won't overflow the parent container. Works fine for tags unless you have massive strings of text without spaces.
.tag {  width: fit-content;  max-width: 100%;}

Then you just get a predictable wrap instead of a broken layout.



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