zoukankan      html  css  js  c++  java
  • 移动端rem设置字体

    css中设置字体单位有三种:px,em,rem

    px是绝对单位,用px设置字可以保证设置的精准度;

    em比较繁琐,所以现在移动端的web流行使用rem作为字体相对单位;

    rem是一种相对单位,相对于本页面的根字体大小而设置;通常用法:

    html{

      font-size:62.5%;

    }

    设置跟字体为62.5%即网页的默认字体一般为16px,这样设置可以令1rem == 10px方便计算;

    针对大小屏幕的适应问题可以通过媒体查询的方法重新设置跟字体大小适应不同大小的手机屏幕eg:

    html{font-size:10px}
    @media screen and (min-321px) and (max-375px){html{font-size:11px}}
    @media screen and (min-376px) and (max-414px){html{font-size:12px}}
    @media screen and (min-415px) and (max-639px){html{font-size:15px}}
    @media screen and (min-640px) and (max-719px){html{font-size:20px}}
    @media screen and (min-720px) and (max-749px){html{font-size:22.5px}}
    @media screen and (min-750px) and (max-799px){html{font-size:23.5px}}
    @media screen and (min-800px){html{font-size:25px}}

  • 相关阅读:
    toj 2975 Encription
    poj 1797 Heavy Transportation
    toj 2971 Rotating Numbers
    zoj 2281 Way to Freedom
    toj 2483 Nasty Hacks
    toj 2972 MOVING DHAKA
    toj 2696 Collecting Beepers
    toj 2970 Hackle Number
    toj 2485 Card Tric
    js页面定位,相关几个属性
  • 原文地址:https://www.cnblogs.com/xiaomingge/p/5969746.html
Copyright © 2011-2022 走看看