[英]Font size issue with iPhone
Im currently working on a mobile version of a website, everything is great, works fine on an iPhone, Blackberry and Android. 我目前正在开发一个网站的移动版本,一切都很棒,在iPhone,黑莓和Android上运行良好。
I have one slight problem, not a big deal but still a little annoying. 我有一个小问题,不是什么大问题,但仍然有点烦人。 I have:
我有:
<h1>
tags set to 18px and bold <h1>
标签设置为18px和粗体
<h2>
tags set to 12px and bold <h2>
标签设置为12px和粗体
<p>
tags set to 12px and normal <p>
标签设置为12px和正常
Now everything looks great on the iPhone when viewing in portrait, but when the device is rotated to landscape the <h1>
titles go smaller (hard to tell but possibly smaller than the <h2>
tags?! 现在,当以纵向观看时,iPhone上的一切看起来都很棒,但是当设备旋转到横向时,
<h1>
标题变得更小(难以分辨但可能小于<h2>
标签?!
Here is my css: 这是我的css:
h1 {
color:#FFFFFF;
font-size:18px;
line-height:22px;
font-weight:bold;
margin-top:0px;
}
h2 {
font-size:12px;
color:#333333;
font-weight:bold;
margin-bottom:-5px;
}
p {
color:#333333;
font-size:12px;
line-height:18px;
font-weight:normal;
}
I believe you are looking for this in your CSS: 我相信你在CSS中寻找这个:
html {
-webkit-text-size-adjust: none; /* Prevent font scaling in landscape */
}
A better solution can be using 100% instead of none, as stated by user612626 in an older thread: Font size rendering inconsistencies on an iPhone 一个更好的解决方案可以使用100%而不是无,正如用户612626在旧线程中所述: iPhone上的字体大小呈现不一致
body {
-webkit-text-size-adjust: 100%;
}
this way desktop webkit browsers can adjust size and zoom proportionally too. 这样桌面webkit浏览器也可以按比例调整大小和缩放。 I think this is a better approach than filtering by screen size.
我认为这比按屏幕大小过滤更好。
Hope it helps. 希望能帮助到你。
As stated in Neurofluxation's answer you can use the css rule -webkit-text-size-adjust but beware that this can prevent users from adjusting the font size on desktop Webkit as well (see this article for more details). 正如Neurofluxation的回答中所述,您可以使用css规则-webkit-text-size-adjust,但要注意这可以防止用户调整桌面Webkit上的字体大小(有关详细信息,请参阅此文章 )。
In light of this it's likely worth checking via CSS3 media queries (or user agent) to be safe. 鉴于此,可能值得通过CSS3媒体查询(或用户代理)进行检查以确保安全。
Eg, 例如,
@media only screen and (max-device-width: 480px) {
html {
-webkit-text-size-adjust: none;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.