Home >Web Front-end >CSS Tutorial >How Can I Prevent Font Size Changes in iPhone Web Apps During Orientation Shifts?

How Can I Prevent Font Size Changes in iPhone Web Apps During Orientation Shifts?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-30 06:31:14334browse

How Can I Prevent Font Size Changes in iPhone Web Apps During Orientation Shifts?

Preserving Font Size in iPhone Orientation Changes

Many web applications encounter a frustrating issue where the font size of hyperlinks changes when the iPhone switches from portrait to landscape mode. To preserve the desired font size, the following steps can be taken:

Firstly, define the font size in the CSS, ensuring it is set as desired in portrait mode. For instance:

ul li a {
    font-size: 14px;
    text-decoration: none;
    color: #cc9999;
}

Next, disable the default behavior using the -webkit-text-size-adjust CSS property. This property prevents scaling of font size. Implement it as follows:

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

The Safari Web Content Guide provides further information on the use of this property. By implementing these steps, the font size of hyperlinks will remain consistent regardless of the iPhone's orientation.

The above is the detailed content of How Can I Prevent Font Size Changes in iPhone Web Apps During Orientation Shifts?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn