functionc(){varb=f.getBoundingClientRect().width;b/i>540&&(b=540*i);varc=b/10;f.style.fontSize=c+"px",k.rem=a.rem=c}這里最后執(zhí)行后設(shè)置的是html的font-size為36px;頁面使用rem,但是在小米自帶瀏覽器上發(fā)現(xiàn)頁面所有元素都要比預(yù)期的小,于是我便打印了一下:console.log(getComputedStyle(window.document.documentElement)['font-size']);//31pxconsole.log(window.document.documentElement.style.fontSize)//36px發(fā)現(xiàn)瀏覽器最終使用的font-size是31不是36,但是第二行代碼得到是我設(shè)置的值36px。搞不懂?。?!在其他瀏覽器上是正常的,兩個打印出來的都是36px
使用js動態(tài)設(shè)置font-size,小米自帶瀏覽器無效
富國滬深
2019-05-25 15:48:31