Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix android webview 里 html font-size 因设置系统字体大小受到影响 #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fzred
Copy link

@fzred fzred commented Aug 23, 2016

如题
比如font-size本来是36px,但因设置系统的字体大小,导致实际的font-size不等于36px。

@blacksunset
Copy link

赞,刚好遇到这个问题

@MeCKodo
Copy link

MeCKodo commented Aug 23, 2017

@fzred 请问为什么是 rem = rem * rem / realitySize; 这个算法的出处是?

十分感谢

@fzred
Copy link
Author

fzred commented Aug 26, 2017

@MeCKodo 比如屏幕宽度为1000,算出rem是100,但因为设置系统字体大小,导致 realitySize 实际是 50(假设缩小了2倍),为了达到10rem == 1000,所以 rem = rem * rem / realitySize ,rem = 100100/*50 ,算出rem为200,再经系统字体缩小2倍后就是100。

@MeCKodo
Copy link

MeCKodo commented Sep 28, 2017

@fzred
var realitySize = parseInt(window.getComputedStyle(document.documentElement).fontSize);

这里不应该用parseInt

@bandow
Copy link

bandow commented Feb 1, 2018

请问 :
function setBodyFontSize () {
if (document.body) {
document.body.style.fontSize = (12 * dpr) + 'px'
}
else {
document.addEventListener('DOMContentLoaded', setBodyFontSize)
}
}
setBodyFontSize();
有什么用?

@linxing1026
Copy link

在vux中我修改了postcss-px-to-viewport的配置 把viewportWidth改为375 viewportHeight 667 vux的个别组件after伪类中会生成viewport-units-buggyfill导致组件有多余文本内容,不知道如何解决

@airen
Copy link
Contributor

airen commented Feb 7, 2018

@linxing1026 这个需要单独对其进行处理。另外可以看看viewport-units-buggyfill的API,看看有没有开头控制。如果没有需要人肉通过 xxxx:after{content: '' !important;}覆盖

@mark1145588963
Copy link

最近在测试中发现华为和一加手机系统字体变大时候,webview h5中元素的宽高不会变化,但是字体大小会变大,请问是为什么呢?宽高、字体大小都是通过rem设置的。

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants