I’m practicing the one thing that scares the hell out of me: responsive CSS.
I made a header like this one, mostly via use of positive/negative margins. However, it becomes a mess once I start changing the viewport’s dimensions.
Were it just a simple h1
(such as only the ‘Grandmaster’), I’d use font-size: 5vw
, and it’d scale. However, since it’s more complex, just throwing vw
units around doesn’t help.
What is the best way to have a complex header like this scale well across all screen sizes?
My idea:
- Make it either a SVG or a JPG, then have a
h1
withdisplay:none
or some other trick (such as moving it off screen with position:absolute) for SEO. The pro is that making it an image is probably the easiest way to let it scale everywhere properly. The con is that, as far as I’m concerned, it still hurts SEO.
Is there one estabilished way to deal with such a case?
2
Answers
try using css media queries for example:
@media screen and (max-width: 790px) this means For screens that are 790px or less, set the font size to 15 px you can read more about it here https://www.w3schools.com/css/css_rwd_mediaqueries.asp
There are many strategies you could go about this one, since it is very opinionated, the best solution would be to keep the text, use some
span
for the various parts of the text and useem
units to size them, then just change thefont-size
on the parent element and the various parts will scale accordingly. Use media queries@media
to change the parent element’sfont-size
in critical breakpoints.