iPhone / iPod - 防止字体大小变化 [英] iPhone/iPod - prevent font-size-changing

查看:178
本文介绍了iPhone / iPod - 防止字体大小变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以防止以下行为:
我有一个* .css文件,其中定义了我的mobile-web-app的字体大小。



html,body {
font-size:16px!important;
}



我没有在我的文件中使用任何其他font-size属性。
现在,当我转到横向模式,字体大小更改。
如何防止或操纵此行为。我必须使用 @media screen和(max-width:x px){} 还是有其他方法?



感谢您的分享。

解决方案

您可能需要使用额外的选择器, p>

  html,body {-webkit-text-size-adjust:none; }因此,此规则不会阻止在WebKit桌面浏览器(Chrome,Safari和即将推出)中调整文字大小的功能(*。 Opera),将其包装在针对所需设备的CSS媒体查询中,例如:

  / * iPhone,portrait&景观。 * / 
@media all和(max-device-width:480px){
html,body {-webkit-text-size-adjust:none; }
}
/ * iPad,portrait&景观。 * /
@media all和(min-device-width:768px)和(max-device-width:1024px){
html,body {-webkit-text-size-adjust:none; }
}


I was wondering whether it is possible to prevent following behaviour: I've got a *.css file in which I define the font-size for my mobile-web-app.

html,body { font-size:16px !important; }

I didn't use any other font-size attributes in my files. Now, when I turn into the landscape mode, the font-size changes. How can I prevent or manipulate this behaviour. Do I have to use @media screen and (max-width: x px) { } or is there any other way?

Thanks for sharing.

解决方案

You may need to use extra selectors but the following should do the trick.

html,body { -webkit-text-size-adjust:none; }

So that this rule doesn't prevent text resizing in WebKit desktop browsers (Chrome, Safari and soon Opera), wrap it in a CSS media query targeting the desired devices like so:

/* iPhone, portrait & landscape. */
@media all and (max-device-width: 480px) {
    html,body { -webkit-text-size-adjust:none; }
}
/* iPad, portrait & landscape. */
@media all and (min-device-width: 768px) and (max-device-width: 1024px) {
    html,body { -webkit-text-size-adjust:none; }
}

这篇关于iPhone / iPod - 防止字体大小变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆