1、通过计算宽度来换算字体比例
<script type="text/javascript">
! function () {
var html = document.documentElement;
var hWidth = html.getBoundingClientRect().width;
html.style.fontSize = hWidth / 15 + 'px';
}();
window.addEventListener('resize', (e) => {
var html = document.documentElement;
var hWidth = html.getBoundingClientRect().width;
html.style.fontSize = hWidth / 15 + 'px';
})
</script>
2、less预编译@r = 50rem;
3、根据二倍图设计稿直接换算
(例如设计稿给高度300px,less编译直接300/@r)
4、字体注意要放大二倍 比如设计稿给16px less编译写32/@r