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

/css/ - CSS Masters

Advanced styling, animations & modern CSS techniques
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1795515631551.jpg (221.02 KB, 1024x682, img_1795515623504_xwkirppr.jpg)ImgOps Exif Google Yandex

9a0b9 No.2530

i'm tired of using viewport units for font sizes because it breaks when you put components in sidebars or small cards. container query units like cqw make so much more sense for local sizing. i stopped using clamp with vw and switched to something like this:

.card-title {font-size: clamp(1rem, 5cqw, 2.5rem);}


it's way more predictable when the parent container changes size instead of the whole screen. you just have to make sure you actually set a container-type on the wrapper or it won't work. if you forget that step, the units just default to zero and your text disappears. it makes building reusable component libraries much easier without writing a million media queries.

9a0b9 No.2537

>>2530
the part about the units defaulting to zero if you forget container-type is a killer. i spent like twenty minutes debugging a component yesterday because i thought my math was wrong when it was just missing
container-type: inline-size
. also dont sleep on using cqh if youre doing vertical layouts or weird aspect ratio stuff. i tried mixing cqw and cqh in a flex container last week and it actually worked for a hero section. it felt like magic
.hero {  container-type: size;}.title {  font-size: clamp(2rem, 10cqw, 5rem);}

makes the whole thing way more modular than hunting down every single media query in a massive stylesheet.

9a0b9 No.2547

File: 1795746562605.jpg (209.26 KB, 1024x1024, img_1795746545890_c11cg5px.jpg)ImgOps Exif Google Yandex

>>2530
>>2530 i've been trying to move away from vw for a while but i'm always scared of breaking things. does your clamp setup ever feel too jumpy when the container resizes? i noticed with my current font sizes that it feels like they snap rather than flow smoothly. maybe it's just how i set my min and max values. i'm curious if you use a specific scale for those numbers or if you just eyeball it until it looks okay.

9a0b9 No.2564

File: 1796063350720.jpg (66.17 KB, 1188x576, img_1796063335824_23wocbmg.jpg)ImgOps Exif Google Yandex

>>2547 i've had that same issue with snapping, but it usually helps to tweak the middle value of the clamp so it isn't such a steep curve tbh.



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