zoukankan      html  css  js  c++  java
  • 怎么设置(控制)移动端的字体大小

    方法一:用css3的媒体查询来设置

    html {font-size:12px}
    @media screen and (min-480px) 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) and (max-959px) {html {font-size: 25px;}}
    @media screen and (min-960px) and (max-1079px) {html {font-size: 30px;}}
    @media screen and (min-1080px) {html {font-size: 32px;}}
    

    方法二:用js来设置

    /*

    *** 12为最小字体大小

    *** 40为最大字体大小

    *** 320屏幕下font-size是12

    */

    document.getElementsByTagName('html')[0].style.fontSize = Math.min(window.innerWidth*12/320,40)+"px";
    

      

  • 相关阅读:
    Shell脚本编程之Shell函数
    Shell脚本编程之流程控制
    Shell脚本编程之Shell命令
    MySQL5.6的optimizer_trace
    Cgroup
    Python的__main__.py用法
    Git提交到github上
    mysql timeout
    数据库大牛
    update and的坑
  • 原文地址:https://www.cnblogs.com/rainheader/p/4629470.html
Copyright © 2011-2022 走看看