您的位置:首页 > 其它

使用rem单位实现布局自适应

2017-04-05 17:58 531 查看
css代码

* {
margin: 0;
padding: 0;
-webkit-overflow-scrolling: touch;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: none;
font-size: 0.6rem;
}

html {
font-family: arial;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
width: 100%;
height: 100%;
font-size: 20px;
}

js代码

var scWid = document.documentElement.offsetWidth||document.body.offsetWidth;
var initScWid = 375;
var initFontSize = 20;

$('html').css({
'fontSize': parseInt((scWid * initFontSize) / initScWid) + 'px'
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: