function c() { var b = f.getBoundingClientRect().width; b / i > 540 && (b = 540 * i); var c = b / 10; f.style.fontSize = c + "px", k.rem = a.rem = c }這里最后執行后設置的是html的font-size為36px;頁面使用rem,但是在小米自帶瀏覽器上發現頁面所有元素都要比預期的小,于是我便打印了一下:console.log(getComputedStyle(window.document.documentElement)['font-size']);//31pxconsole.log(window.document.documentElement.style.fontSize)//36px發現瀏覽器最終使用的font-size是31不是36,但是第二行代碼得到是我設置的值36px。搞不懂?。?!在其他瀏覽器上是正常的,兩個打印出來的都是36px
使用js動態設置font-size,小米自帶瀏覽器無效
哆啦的時光機
2018-12-12 18:13:29