Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preserve HTML font-size when iPhone orientation changes from portrait to landscape

Tags:

html

css

iphone

I have a mobile web application with an unordered list containing multiple items with a hyperlink inside each li:

My question is: how can I format the hyperlinks so that they DON'T change size when viewed on an iPhone, and the accelerometer switches from portrait to landscape?

In portrait mode, I have the hyperlink font size set at 14px, but when I switch the device to landscape, it blows way up to 20px.

I would like the font-size to stay the same.

Here is the example code:

ul li a {
    font-size:14px;
    text-decoration: none;
    color: #cc9999;
}
<ul>
    <li id="home" class="active">
      <a href="home.html">HOME</a>
    </li>
    <li id="home" class="active">
      <a href="test.html">TEST</a>
    </li>
</ul>
like image 987
DShultz Avatar asked Oct 09 '22 01:10

DShultz


1 Answers

You can disable this behavior through the -webkit-text-size-adjust CSS property:

html {
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape while allowing user zoom */
}

The use of this property is described further in the Safari Web Content Guide.

like image 465
Matt Stevens Avatar answered Oct 16 '22 22:10

Matt Stevens