Is there such a thing as min-font-size and max-font-size?

前端 未结 11 584
隐瞒了意图╮
隐瞒了意图╮ 2021-01-29 22:13

I\'m trying to make a font in a div responsive to the browser window. So far, it has worked perfectly, but the parent div has a max-width of 525px. Res

11条回答
  •  太阳男子
    2021-01-29 22:19

    It works well with CSS.

    I went through the same issues and fixed it as follow.

    Use a fixed "px" size for maximum size at a specific width and above. Then for different smaller widths, use a relative "vw" as a percentage of the screen.

    The result below is that it adjusts itself at screens below 960px but keep a fixed size above. Just a reminder, not to forget to add in the html doc in header:

    
    

    Example in CSS:

    @media all and (min-width: 960px) {
    h1{
        font-size: 50px;
      }
    }
    
    @media all and (max-width: 959px) and (min-width: 600px) {
    h1{
        font-size: 5vw;
      }
    }
    
    @media all and (max-width: 599px) and (min-width: 50px) {
    h1{
        font-size: 6vw;
      }
    }
    

    I hope it'll help!

提交回复
热议问题