【问题标题】:Inconsistent font size on Mobile View depending on div height?移动视图上的字体大小不一致取决于 div 高度?
【发布时间】:2018-11-13 06:28:01
【问题描述】:
我的 HTML 的相关部分如下所示:
<div class="container-main">
<p>TEXT HERE<\p>
</div>
我的 CSS 如下所示:
p {
font-size: 20px;
}
.container-mobile {
background-color: white;
margin-top: 100vh;
width: 100wv;
height: 600px;
}
即使我将字体大小设置为 16 像素,移动设备上的文字也非常小。如果我将高度更改为“自动”,字体会突然变大。为什么改变?在移动设备中处理字体大小的首选方法是什么?
【问题讨论】:
标签:
html
css
mobile
font-size
【解决方案1】:
将视口添加到页面的标题部分解决了问题
p {
font-size: 20px;
}
.container-mobile {
background-color: white;
margin-top: 100vh;
width: 100wv;
height: 600px;
}
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<div class="container-main">
<p>TEXT HERE</p>
</div>