html – Scalable font size (responsive?)

Question:

Is there a way to make the font size autoscalable based on the screen size?

I have tried to put in rem, in% but it does not work for me.

Answer:

As an extension to what colleague Error404 has commented, tell you two things.

You can control the font size with the width of your screen:

.mifuente {
    font-size: 2vw;
}

Or you can do it with the high:

.mifuente {
    font-size: 2vh;
}

In more specific cases, you have no alternative to using @media to do one thing or another depending on your height and width.

@media (max-width: 200px) and (max-heigth: 160px) {
    .mifuente {
        font-size: 20px;
    }
}
Scroll to Top