<script type="text/javascript">
// px转rem
var rootResize = function() {
var baseFontSize = 100;
var baseWidth = 750;
var minWidth = 320;
var clientWidth = document.documentElement.clientWidth || window.innerWidth;
var innerWidth = Math.max(Math.min(clientWidth, baseWidth), minWidth);
var rem = clientWidth / (baseWidth / baseFontSize);
if (innerWidth == 750 || innerWidth == 320) {
rem = innerWidth / (baseWidth / baseFontSize)
}
document.querySelector('html').style.fontSize = rem + 'px';
};
rootResize();
window.οnresize = function() {
rootResize()
};
</script>
css:
html {
font-size: 100px;
font-family:PingFang SC;
/*line-height: .45rem;*/
font-weight:400;
padding: 0;
margin: 0;
}