iPhone/iPod - prevent font-size-changing

白昼怎懂夜的黑 提交于 2019-12-12 07:15:09

问题


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.


回答1:


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; }
}


来源:https://stackoverflow.com/questions/6094324/iphone-ipod-prevent-font-size-changing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!