Responsive font size in CSS

前端 未结 30 2760
刺人心
刺人心 2020-11-22 07:23

I\'ve created a site using the Zurb Foundation 3 grid. Each page has a large h1:

30条回答
  •  无人及你
    2020-11-22 08:08

    The text size can be set with a vw unit, which means the "viewport width". That way the text size will follow the size of the browser window:

    https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_responsive_text

    For my personal project I used vw and @meida. It works perfectly.

    .mText {
        font-size: 6vw;
    }
    
    @media only screen and (max-width: 1024px) {
        .mText {
            font-size: 10vw;
        }
    }
    
    
    .sText {
        font-size: 4vw;
    }
    
    @media only screen and (max-width: 1024px) {
        .sText {
            font-size: 7vw;
        }
    }
    

提交回复
热议问题