当 iPhone 方向从纵向变为横向时保留 HTML 字体大小 [英] Preserve HTML font-size when iPhone orientation changes from portrait to landscape

查看:27
本文介绍了当 iPhone 方向从纵向变为横向时保留 HTML 字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个无序列表的移动网络应用程序,其中包含多个项目,每个li 内有一个超链接:

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

我的问题是:如何设置超链接的格式,以便在 iPhone 上查看时它们不会改变大小,并且加速度计从纵向切换到横向?

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?

在纵向模式下,我将超链接字体大小设置为 14px,但是当我将设备切换到横向模式时,它会上升到 20px.

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.

示例代码如下:

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>

推荐答案

您可以通过 -webkit-text-size-adjust CSS 属性禁用此行为:

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 */
}

Safari Web 内容指南.

这篇关于当 iPhone 方向从纵向变为横向时保留 HTML 字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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