html - 如何让 CSS 表格列对齐?

标签 html css

我正在处理一个 CSS 表格,结果出乎意料 - 表格列没有正确排列。这是表格的样子

enter image description here

这是CSS

* {
    /* old-style reset here :) */
    border: 0px;
    padding: 0px;
}

table {
    border-collapse: separate;
    border: 1px solid #9DABCE;
    border-width: 0px 0px 1px 1px;
    margin: 10px auto;
    font-size: 20px;
    width:90%;
}
td, th {
    width: 41px;
    height: 41px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    vertical-align: middle;
    background: url(../img/cells.png);
    color: #444;
    position: relative;
}
th {
    font-weight: bold;
    font-size: 14px;
}
td.today {
    background-position: 81px 0px;
    color: white;
}

这是表格 HTML

 <table cellspacing="0">
            <thead>
                    <th>Core Measure</th><th>National Average</th>
            </thead>
            <tbody>
                <tr>
                    <td class="today">Discharge Instructions</td>
                    <td class="today">91%</td>
                </tr>
                <tr>
                    <td class="today">Measure LV Systolic Function</td>
                    <td class="today">98%</td>
                </tr>
                <tr>
                    <td class="today">ACE/ARB for LVSD</td>
                    <td class="today">95%</td>
                </tr>
                <tr>
                    <td class="today">Smoking Cessation</td>
                    <td class="today">99%</td>
                </tr>
            </tbody>
            <tfoot>
                    <th>Core Measure</th><th>National Average</th>
            </tfoot>
        </table>

如能协助解决此问题,我们将不胜感激。谢谢。

最佳答案

这与您的 Sprite 和您设置的背景位置值有关。我做了一个fiddle对你来说似乎没问题。

关于html - 如何让 CSS 表格列对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11266330/

相关文章:

html - div 在屏幕上高于父 div 时被截断

php - 使用 INCLUDE 函数时 CSS 失败

c# - 使用 C# 将 HTML 转换为图像。 Html 有标签以及 base64 字符串问题

html - Internet Explorer 中的渐变颜色

html - 使用 Firefox 或 Chrome 打开时,Rmarkdown 生成的 html 文件中未显示 Pdf 图

javascript - 有没有办法从 Javascript 中的 <a> 链接访问包含的 div?

html - 文本旁边垂直居中图标

javascript - 100% View 高度和宽度 div 滚动

css - Facebook Javascript SDK 在 Firefox 的响应式 Twitter Bootstrap 页面中导致额外的边距/填充

javascript - 单击一次将图像从其设置位置移动,然后单击一下返回到原始位置?