首页 > 移动平台 > 详细

移动端使用rem方法

时间:2018-10-10 13:47:32      阅读:158      评论:0      收藏:0      [点我收藏+]

1 在可以设置网页标题栏的页面写一个匹配手机的方法

<script>
       function resetWidth() {
            // 兼容ie浏览器 document.body.clientWidth
            var baseWidth = document.documentElement.clientWidth || document.body.clientWidth;
            console.log(baseWidth);
            // 默认的设置是375px(ip6)的根元素设为100px, 其他的手机都相对这个进行调整
            document.documentElement.style.fontSize = baseWidth / 375 * 100 + ‘px‘
        }
        resetWidth();
        window.addEventListener(‘resize‘, function () {
            resetWidth();
        })      
    </script>

 然后在html根目录设置默认大小

 

移动端使用rem方法

原文:https://www.cnblogs.com/gfweb/p/9765561.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!