移动端媒体查询设置字体大小适配不同机型(rem)

Posted wxl99180426

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了移动端媒体查询设置字体大小适配不同机型(rem)相关的知识,希望对你有一定的参考价值。

@media screen and (min-width: 320px) {
  html {
    font-size: 8.5333px !important;
  }
}

@media screen and (min-width: 360px) {
  html {
    font-size: 9.6px !important;
  }
}

@media screen and (min-width: 375px) {
  html {
    font-size: 10px !important;
  }
}

@media screen and (min-width: 384px) {
  html {
    font-size: 10.24px !important;
  }
}

@media screen and (min-width: 411px) {
  html {
    font-size: 10.96px !important;
  }
}

@media screen and (min-width: 414px) {
  html {
    font-size: 11.04px !important;
  }
}

@media screen and (min-width: 448px) {
  html {
    font-size: 11.9467px !important;
  }
}

@media screen and (min-width: 480px) {
  html {
    font-size: 12.8px !important;
  }
}

@media screen and (min-width: 512px) {
  html {
    font-size: 13.6533px !important;
  }
}

@media screen and (min-width: 544px) {
  html {
    font-size: 14.5067px !important;
  }
}

@media screen and (min-width: 576px) {
  html {
    font-size: 15.36px !important;
  }
}

@media screen and (min-width: 608px) {
  html {
    font-size: 16.2133px !important;
  }
}

@media screen and (min-width: 640px) {
  html {
    font-size: 17.0667px !important;
  }
}

@media screen and (min-width: 750px) {
  html {
    font-size: 20px !important;
  }
}

@media screen and (min-width: 768px) {
  html {
    font-size: 20.48px !important;
  }
}

@media screen and (min-width: 800px) {
  html {
    font-size: 21.3333px !important;
  }
}

@media screen and (min-width: 1024px) {
  html {
    font-size: 27.3067px !important;
  }
}

 一般的设计稿宽度为375px或者750px;当设计稿为375时,此时的1rem = 10px;当设计稿为750时,此时的1rem = 20px;然后对照着设计稿上的尺寸开发就可以了

以上是关于移动端媒体查询设置字体大小适配不同机型(rem)的主要内容,如果未能解决你的问题,请参考以下文章

移动端适配方案

移动Web开发之rem实际开发适配方案

移动端适配-px转成rem

rem 适配布局 + LESS + 媒体查询

0082 rem适配方案:less+rem+媒体查询flexible.js+rem

rem适配,解决用户设置系统字体大小导致样式错乱问题