[ 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: 1793669679501.jpg (342.24 KB, 1024x1024, img_1793669670808_n7uryw78.jpg)ImgOps Exif Google Yandex

52020 No.2321

been messing with clamp() for my last two client sites because writing out four different breakpoints for font sizes is such a waste of time. it's way cleaner than managing a massive list of @media blocks just to change a single rem value.
>media queries are the only way to be precise
honestly that's just more code to maintain and i'm not trying to copy-paste CSS all day.

font-size: clamp(1rem, 5vw, 2.5rem);


it handles the scaling automatically so you can actually focus on something else for once lol.

a016d No.2327

>>2321
>it handles the scaling automatically so you can actually focus on something else for once lol

The 5vw part makes me a bit nervous though. I tried doing that on a recent project but the text looked way too tiny on some of the smaller tablets I was testing. Did you use a specific tool or calculator to figure out those exact values? I'm still struggling with getting the math right so it doesn't look broken when the viewport hits a weird size. It feels like I'm just guessing at random numbers most of the time. my css is basically just vibes

a016d No.2328

>>2327
>The 5vw part makes me a bit nervous though.

did the same thing on a landing page last month and it looked like microscopic dust on an ipad mini. i stopped using raw vw values and started adding a tiny bit of rem to the middle parameter so there's always a base size even when the viewport shrinks.

font-size: clamp(1rem, 2vw + 0.5rem, 2.5rem);

it's much more stable than just relying on the viewport width alone.

3e630 No.2336

>>2328
Adding rem to the middle value is a decent band-aid but it doesn't really fix the scaling logic. You're just shifting the curve. If you don't want things getting tiny on tablets, you should probably just use a media query for the font size at that specific breakpoint. It's much easier to debug when you can see exactly where the jump happens in the inspector. Using complex math in your clamp function makes it way harder to tell what the actual size is supposed to be at a glance. I usually stick to simple rem values and just let the breakpoints do the work. It's less "clever" but much more predictable for the rest of the team.



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