解决因为手机设置字体大小导致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
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
相关文章推荐
- 解决因为手机设置字体大小导致h5页面在webview中变形的bug
- 解决因为手机设置字体大小导致h5页面在webview中变形的BUG
- 解决因为手机设置字体大小导致h5页面在webview中变形的BUG
- 解决因手机设置字体大小导致h5页面在webview中变形的BUG
- android webview 加载H5页面,设置字体不随系统设置变化
- 设置webview 的字体大小,字体颜色和页面背景
- H5 手机页面字体显示大小与css设置不一致,viewport影响font-size问题
- 解决 ios 11 和 h5 页面在 wkwebview 上显示, footer 设置 bottom 为 0 时, 顶部会出现留白
- ScrollView与WebView结合使用时,设置webview字体大小的时候出现下方留白解决
- webView设置字体大小以及文章末尾的留白解决
- iOS中通过设置CSS改变WebView字体大小,颜色,背景颜色
- android应用因为加入js而导致webview一直在加载中的bug解决方案
- iOS中通过设置CSS改变WebView字体大小,颜色,背景颜色
- WebView设置字体颜色, 字体大小,背景
- 解决 hybird 应用中重复获取 WebView,导致页面元素无法识别的问题
- iOS 修改webView字体大小,设置宽度及缩放效果
- iOS 修改webView字体大小,设置宽度及缩放效果
- Android的WebView中设置使用缓存将导致重定向页面的404结果不可见
- 解决webview闪屏,加载html富文本,设置字体view自动恢复
- iOS中通过设置CSS改变WebView字体大小,颜色,背景颜色