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
ἔρως
ἔρως3w 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
wandererOP3w ago
So it's accessible based on the default font size the user has set for themselves?
ἔρως
ἔρως3w ago
exactly
wanderer
wandererOP3w 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?
ἔρως
ἔρως3w ago
*element not elements for everything else, you already have the clamp and rem + vw size
wanderer
wandererOP3w ago
Are they just added with calc? I don't fully get that, but I'm seeing that approach on MDN now
ἔρως
ἔρως3w ago
no, clamp accepts math stuff
wanderer
wandererOP3w ago
I don't get the idea behind it yet
ἔρως
ἔρως3w 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
wandererOP3w 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
ἔρως
ἔρως3w ago
you can try 5vw but play around with it
wanderer
wandererOP3w ago
I see
ἔρως
ἔρως3w ago
just don't go overboard or it goes from the minimum size to the maximum size in no time
wanderer
wandererOP3w ago
Yeah that makes sense I can "close the post" if my question is answered right?
ἔρως
ἔρως3w ago
just add the "solved" tag
wanderer
wandererOP3w ago
This is the first time I'm using this part of Discord to ask questions
ἔρως
ἔρως3w ago
you have to edit the post to add it, all the way at the top
wanderer
wandererOP3w ago
Yeah I've done so, thanks again for answering my questions
ἔρως
ἔρως3w ago
you're welcome
wanderer
wandererOP2w 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.
ἔρως
ἔρως2w 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
wandererOP2w ago
I'm doing this with text that looks decorative, otherwise, user settings can just ruin the design
ἔρως
ἔρως2w 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
wandererOP2w 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
ἔρως
ἔρως2w 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
wandererOP2w ago
yeah didn't cross my mind
ἔρως
ἔρως2w ago
that always throws a wrench on stuff
wanderer
wandererOP2w 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.
ἔρως
ἔρως2w ago
it isn't odd using px isn't accessible, but there is nothing odd about it the .6px is weird, but well
Want results from more Discord servers?
Add your server