html - 在 Internet Explorer 7 中,文本对齐 : right is not taking effect

标签 html css internet-explorer

有什么办法可以让header向右对齐吗?
仅在 Internet Explorer 7 中测试。

<html>
    <style type="text/css">
        th {
            text-align: left;
        }
    </style>
<body>
    <table width="100%" border="1">
        <thead>
            <tr>
                <th style="width: 250px;">Tag
                <th style="width: 100px; text-align: right;">Duration
            </tr>
        </thead>
        <tbody>
            <tr>
                <td > one
                <td> two
            </tr>
        </tbody>
    </table>
</body>
</html>

最佳答案

首先,关闭您的标签。这里有很多无效的 HTML。其次,您将表格宽度 (100%) 混合为百分比,将单元格宽度(250 像素、100 像素)混合为像素宽度。这两个不兼容。选择一个或另一个并在整个表格中保持一致。

<table style="width:350px" border="1">
    <thead>
        <tr>
            <th style="width:250px;">Tag</th>
            <th style="width:100px; text-align:right;">Duration</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>one</td>
            <td>two</td>
        </tr>
    </tbody>
</table>

关于html - 在 Internet Explorer 7 中,文本对齐 : right is not taking effect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1954550/

相关文章:

html - 使网站 Logo 在保持居中的同时适用于不同的设备

javascript - 为什么 Jquery .click() 会触发多个函数?

php - 使用 PHP 将 CSS 样式应用于 MySQL 数据获取

jquery - 动画 block 高度从 0 到自动

html - 为什么人们缩小 Assets 而不是 HTML?

javascript - 使用 jQuery 获取包括 HTML 元素的选择选项

jquery - 文本框展开时文本框背景不跟随

javascript - 阐明 IE 中的 clearTimeout 行为

internet-explorer - Watir Webdriver 文本在 IE 上输入缓慢

windows - 在 Windows 上,当我的子窗口的 z 顺序相对于其 sibling 之一发生变化时,它是否应该获得 WM_WINDOWPOSCHANGED?