原本css是3.5vw
安卓h5不兼容 系统设置超大字体 会撑开DIV
添加如下代码
新写法 3.5rem
系统超大字体 1vw = 1rem
<script type="text/javascript">
(function (doc, win) {
var fontSize_d = 16;//默认字体大小
var fontSize =0;
try {
fontSize = parseInt(document.defaultView.getComputedStyle(document.documentElement,null)['fontSize']);
} catch (error) {}
if(!(fontSize>0))fontSize = fontSize_d;//字体大小读取失败
var cz = fontSize_d/fontSize;
var docEl = document.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = (parseInt((docEl.clientWidth /100)*cz*100) / 100 )+ 'px';
docEl.style.fontSize = clientWidth;//100 * (clientWidth / 750) + 'px';
// document.body.style.fontSize = clientWidth;
console.log(clientWidth,fontSize,cz);
};
recalc();
window.addEventListener(resizeEvt, recalc, false);
})(document, window)
</script>