在使用css属性处理时,我发现Android的Web视图行为很奇怪:
显示包含以下css属性的网页时:font-size
和line-height
set:
font-size: 20px;
line-height: 35px;
Android的webview将属性更改为:
font-size: 17.4px;
line-height: 30.45px;
为什么?
我找到了答案:
只需webView必须在android中将文本大小设置为“NORMAL”。像这样:
webView.getSettings().setTextSize(WebSettings.TextSize.NORMAL);
您是否检查了不同分辨率的页面行为? CSS中可能有定义的@media
规则,它们会改变不同分辨率的样式,例如:
@media screen and (min-width: 1024px) {
p {
font-size:20px;
line-height:35px
}
}
@media screen and (max-width: 1023px) {
p {
font-size:17.4px;
line-height:30.45px
}
}
阅读更多here。