rem 就是给根标签html动态设置font-size
1.
2、 vw(iphone6为基准)
100px=1rem
移动端必备:
3、新建rem.js
function remSize() {
var deviceWidth = document.documentElement.clientWidth || window.innerWidth
if (deviceWidth >= 750) deviceWidth = 750
if (deviceWidth <= 320) deviceWidth = 320
document.documentElement.style.fontSize = (deviceWidth / 7.5) + 'px'
document.querySelector('body').style.fontSize = 0.3 + 'rem'
}
remSize();
window.onresize = function () {
remSize()
}
在html页面中引入即可
4、简单粗暴
html{
font-size:100px!important;
}
p{
font-size:.16rem;
}