您的位置:首页 > 移动开发

解决因为手机设置字体大小导致h5页面在webview中变形的BUG

2017-06-16 11:11 573 查看
function
htmlFontSize(){
var h =
Math.max(document.documentElement.clientHeight,
window.innerHeight || 0);
var w =
Math.max(document.documentElement.clientWidth,
window.innerWidth || 0);
var width
= w > h ? h : w; width = width > 720
? 720
: width var
fz = ~~(width*100000/36)/10000
document.getElementsByTagName("html")[0].style.cssText
= 'font-size: '
+ fz +"px";
var realfz
= ~~(+window.getComputedStyle(document.getElementsByTagName("html")[0]).fontSize.replace('px','')*10000)/10000
if (fz
!== realfz) { document.getElementsByTagName("html")[0].style.cssText
= 'font-size: '
+ fz * (fz / realfz) +"px";
}}

源自:http://blog.csdn.net/FungLeo/article/details/73309396
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: