Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone/iPod - prevent font-size-changing

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.

like image 407
glup Avatar asked May 23 '11 07:05

glup


People also ask

Why does my iPhone font size keep changing?

If the font changes, it's because the app you have open changed it, not you. But that doesn't mean you can't edit the text at all. Every iPhone lets you change the font size, making it either bigger or smaller. This is great for users with impaired vision, or with magnified screens.

Why does my font size keep changing on iPad?

The zoom setting is on. You can turn it off via accessibility settings or double tap with three if gers and move three fingers down on the screen.


1 Answers

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; }
}
like image 142
Marcel Avatar answered Oct 01 '22 19:10

Marcel