Quirks 模式表格和文本对齐问题

发布于 2024-08-22 12:35:08 字数 1798 浏览 4 评论 0原文

我有以下 html 代码片段:-

<html>
<head>
    <style>
        body ul
        {
            margin: 0px;
            border: 1px solid black;
            padding: 0px;
            list-style-type: none;
        }
        ul li {
        display: inline;
            padding: 0px;
            margin: 0px;
            border: 1px solid red;
        }
        table
        {
            display: inline;
            margin: 0px;
            padding: 0px;
            border:1px solid green;

        }

    </style>
</head>
<body>
<ul>
        <li>Item1</li>
        <li>Item2</li>
        <li>
            <table>
                <tbody>
                    <tr>
                        <td>Item3</td>
                        <td>Stars</td>
                    </tr>
                </tbody>
            </table>
        </li>
    </ul>

</body>
    </html>

我必须以怪异模式渲染此代码(由于页面中存在 Iframe,为了正确渲染它,我发现怪异模式最适合)。我看到 IE8 显示的代码为: 替代文本
(来源:ggpht.com)

表格与其他列表项不对齐。 而 mozilla 将其显示为:-

替代文字
(来源:ggpht.com)

此处表格已对齐,但文本未对齐。

这里出了什么问题?如何跨浏览器修复此问题

I have the following html code snippet :-

<html>
<head>
    <style>
        body ul
        {
            margin: 0px;
            border: 1px solid black;
            padding: 0px;
            list-style-type: none;
        }
        ul li {
        display: inline;
            padding: 0px;
            margin: 0px;
            border: 1px solid red;
        }
        table
        {
            display: inline;
            margin: 0px;
            padding: 0px;
            border:1px solid green;

        }

    </style>
</head>
<body>
<ul>
        <li>Item1</li>
        <li>Item2</li>
        <li>
            <table>
                <tbody>
                    <tr>
                        <td>Item3</td>
                        <td>Stars</td>
                    </tr>
                </tbody>
            </table>
        </li>
    </ul>

</body>
    </html>

I have to render this code in quirks mode(Due to an Iframe in the page, to render it properly I found that Quirks mode suits the best). I see that IE8 displays the code as:
alt text
(source: ggpht.com)

Table not aligned with the other list items.
Whereas mozilla displays it as :-

alt text
(source: ggpht.com)

Here the table is aligned but the text is not.

What is going wrong here? How do I fix this across browsers

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

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

发布评论

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

评论(1

一个人练习一个人 2024-08-29 12:35:08

坚持怪癖模式?好的。

看起来表格中的 td 有填充,导致它像 IE 中那样呈现。

尝试删除表格后所有元素的填充+边距。

Insist on quirks mode? OK.

It looks like the td within the table has padding that causes it to render like that in IE.

Try removing padding+margin on all elements after table.

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