使用 colspan 旋转 iPhone 进行 TD 时出现奇怪的行为

发布于 2024-11-19 06:09:23 字数 1909 浏览 2 评论 0原文

这是关于在 iPhone 的浏览器中显示一个简单的 HTML 页面,并进行旋转。

设置:两个相同的表格,但其中一个 (CSS) 宽度为 69%,而另一个为 100%。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable = yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>Test</title>
    <style>
    table
    {
        border-collapse: collapse;
    }
    th
    {
        font-weight: normal;
        border: 1px solid red;
    }
    td
    {
        border: 1px solid green;
    }
    #t1
    {
        width: 69%;
    }
    #t2
    {
        width: 100%;
    }
    </style>
</head>
<body>
    <table id="t1">
        <tr><th colspan="2">TH COLSPAN 2</th></tr>
        <tr><td colspan="2">TD COLSPAN 2</td></tr>
        <tr><td>CELL 1</td><td>CELL 2</td></tr>
    </table>
    <hr />
    <table id="t2">
        <tr><th colspan="2">TH COLSPAN 2</th></tr>
        <tr><td colspan="2">TD COLSPAN 2</td></tr>
        <tr><td>CELL 1</td><td>CELL 2</td></tr>
    </table>
</body>
</html>

行为:尽管两个表格在默认方向(纵向)下以相同的字体大小显示,但在旋转设备时,全宽表格会以 形式显示 COLSPAN=2 的 TD/TH更大的字体大小(屏幕截图取自iPhone):

Portrait Landscape

这似乎是 Safari 中的一个错误,但尽管如此,我必须解决它。

关于一个体面的解决方法有什么想法吗?

谢谢。

This is about displaying a simple HTML page in iPhone's browser, with rotation.

Setup: two identical tables but one of them has a (CSS) width of 69% while the other is at 100%.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable = yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>Test</title>
    <style>
    table
    {
        border-collapse: collapse;
    }
    th
    {
        font-weight: normal;
        border: 1px solid red;
    }
    td
    {
        border: 1px solid green;
    }
    #t1
    {
        width: 69%;
    }
    #t2
    {
        width: 100%;
    }
    </style>
</head>
<body>
    <table id="t1">
        <tr><th colspan="2">TH COLSPAN 2</th></tr>
        <tr><td colspan="2">TD COLSPAN 2</td></tr>
        <tr><td>CELL 1</td><td>CELL 2</td></tr>
    </table>
    <hr />
    <table id="t2">
        <tr><th colspan="2">TH COLSPAN 2</th></tr>
        <tr><td colspan="2">TD COLSPAN 2</td></tr>
        <tr><td>CELL 1</td><td>CELL 2</td></tr>
    </table>
</body>
</html>

Behaviour: although the two tables are displayed with the same font size in the default orientation (portrait), when rotating the device the full width table displays TDs/THs having a COLSPAN=2 in a bigger font size (screenshots are taken from iPhone):

Portrait
Landscape

This seems to be a bug in Safari but, nonetheless, I have to get around it.

Any idea about a decent workaround?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-11-26 06:09:23

这是因为有时 Safari webview 会在认为这是个好主意时自动缩放文本。

要禁用此行为,请将此添加到您的正文 CSS 样式:

-webkit-text-size-adjust:none;

This is because sometimes Safari webview Zooms text automatically when it thinks its a good idea.

To disable this behavior add this to your body CSS Style:

-webkit-text-size-adjust:none;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文