using rems with a pixel fallback

前端 未结 2 1659
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-20 00:15

I\'m working on mobile first framework. The project has a broad range of requirements, with a mass of browsers and devices over various locations to cater for. One of my key

2条回答
  •  无人及你
    2021-01-20 01:04

    Either style declaration will work for you - if a browser doesn't support rems it will fall back to the pixel value.

    This is one of those situations where I set the html font-size to 62.5% to take the base font-size down to 10px. This makes the calculations very straight forward and is easy to spot errors in your type declarations.

    html {
      font-size: 62.5%;
    }
    body {
      font-size: 14px;
      font-size: 1.4rem;
    }
    

提交回复
热议问题