Skip to content

Instantly share code, notes, and snippets.

@loo2k
Created October 8, 2013 07:33
Show Gist options
  • Save loo2k/6880985 to your computer and use it in GitHub Desktop.
Save loo2k/6880985 to your computer and use it in GitHub Desktop.

Revisions

  1. loo2k created this gist Oct 8, 2013.
    17 changes: 17 additions & 0 deletions font-size-rem.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    /*
    * 1. rem 单位是基于根元素(html)计算大小的
    * 2. 几乎所有的浏览器根元素字体大小都是 16px
    * 3. 将 html 元素的字体大小调整到 10px 方便使用 rem
    * 4. 采用层叠的方法兼容那些不支持 rem 单位的浏览器
    */
    html {
    /* 对应值为 font-size: 10px; */
    font-size: 62.5%;
    }

    body {
    /* 兼容不支持 rem 单位的浏览器 */
    font-size: 12px;
    /* 对应的值为 12px */
    font-size: 1.2rem;
    }