关于移动端不同分辨率的处理办法

1.标明浏览器视窗

 

    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

2.使用rem 或者em而不使用px

 

        function auto(){
            var width = $('body').width();
            var font_size = 0.8+'rem';//设置默认字体大小
            //var font_size2 = (width/320)*625+'%';//设置根节点字体大小 ps:默认根节点font-size:16*6.25 =100px
            var font_size2 = (width/320)*20+'px';//设置根节点字体大小 ps:默认根节点20px
            if (width>414) {
                font_size2= (414/320)*20+'px';
            }
            $('body').css('font-size',font_size);
            $('html').css('font-size',font_size2);
        }     
        auto();
        window.onorientationchange = function() {
            auto();
        };
        window.onresize = function(){
            auto();
        };

 

3.媒体查询 在使用 bootstrap 等样式标准下一般已经帮我们做了 或者使用以下代码进行根font-size的设置

 

 


   

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值