How to make a page both scale with viewport size and also be accessible for people zooming in.

Making a page responsive, I've once resorted to sizing elements with vw/vh, however that can make it difficult to zoom in on text so it's bad for accessibility. What's a good general approach?
29 Replies
ἔρως
ἔρως2mo ago
use rem and vw in a clamp in #front-end there are posts with good examples and don't use pixels for font sizes, even in the body or html elements by the way, the rem + vw value goes in the middle
wanderer
wandererOP2mo ago
So it's accessible based on the default font size the user has set for themselves?
ἔρως
ἔρως2mo ago
exactly
wanderer
wandererOP2mo ago
Alright, I'll keep this approach in mind, thanks a lot. when you say html elements, I should avoid using pixels for even basic divs?
ἔρως
ἔρως2mo ago
*element not elements for everything else, you already have the clamp and rem + vw size
wanderer
wandererOP2mo ago
Are they just added with calc? I don't fully get that, but I'm seeing that approach on MDN now
ἔρως
ἔρως2mo ago
no, clamp accepts math stuff
wanderer
wandererOP2mo ago
I don't get the idea behind it yet
ἔρως
ἔρως2mo ago
no need for calc the idea is that you set a maximum and minimum size for the text then you have a size in the middle, which will be calculated with viewport units that size will go as low as the minimum, but as high as the maximum and is still zoomable
wanderer
wandererOP2mo ago
I get that, but when we do rem + vw, how much vw is being added? I understand that vw basically should be a factor here
ἔρως
ἔρως2mo ago
you can try 5vw but play around with it
wanderer
wandererOP2mo ago
I see
ἔρως
ἔρως2mo ago
just don't go overboard or it goes from the minimum size to the maximum size in no time
wanderer
wandererOP2mo ago
Yeah that makes sense I can "close the post" if my question is answered right?
ἔρως
ἔρως2mo ago
just add the "solved" tag
wanderer
wandererOP2mo ago
This is the first time I'm using this part of Discord to ask questions
ἔρως
ἔρως2mo ago
you have to edit the post to add it, all the way at the top
wanderer
wandererOP2mo ago
Yeah I've done so, thanks again for answering my questions
ἔρως
ἔρως2mo ago
you're welcome
wanderer
wandererOP2mo ago
@ἔρως so I've written something like this to make a "decorative" header look more responsive. I like how it looks, but are there issues with this approach?
font-size: clamp(36px, calc(100vw*45/399), 49.6px);
font-size: clamp(36px, calc(100vw*45/399), 49.6px);
I'm basically just sizing things proportionate to how they look on the design as the width of the screen changes. I use this for other elements too if I just want something to keep looking the same as the screen stretches. I don't intend to make this a forever thread, this should be the last thing.
ἔρως
ἔρως2mo ago
yes: your font size is in pixels that's very bad for accessibility if the user has set a larget font size by default, this will ignore it convert the pixel values to rems
wanderer
wandererOP2mo ago
I'm doing this with text that looks decorative, otherwise, user settings can just ruin the design
ἔρως
ἔρως2mo ago
let the user ruin the design if i want to make a style that makes your site pink neon with sparkles, i should be allowed to
wanderer
wandererOP2mo ago
I'm planning to also make the minimum and maximum clamp values based on rem in some cases while the middle point takes on pixel values in between, that should work right? Problem is, the header won't look the same with rems
ἔρως
ἔρως2mo ago
not quite, as 1rem isn't always 16px what you can do is to use viewport units like how you are doing now
wanderer
wandererOP2mo ago
yeah didn't cross my mind
ἔρως
ἔρως2mo ago
that always throws a wrench on stuff
wanderer
wandererOP2mo ago
Issue right now is, I want to keep the design looking as it is, but also make things accessible I think I'll just leave the paragraphs at 1rem kindaa basically, but just size all decorative text (including fancy headers) in pixels. I just worry that my approach is odd cause I never saw it before but does exactly what I want.
ἔρως
ἔρως2mo ago
it isn't odd using px isn't accessible, but there is nothing odd about it the .6px is weird, but well

Did you find this page helpful?