CSS + HTML:如何绘制表/单元格边框

时间:2010-12-31 03:11:09

标签: html css html-table cross-browser

这是我的表格的CSS代码:

table.t_data
{
    /* border: 1px; - **EDITED** - doesn't seem like influences here */
    background-color: #080;
    border-spacing: 1px;
    margin: 0 auto 0 auto;
}
table.t_data thead th, table.t_data thead td
{
    background-color: #9f9;
    /* border: #080 0px solid; - **EDITED** - doesn't seem like influences here */
    padding: 5px;
    margin: 1px;
}
table.t_data tbody th, table.t_data tbody td
{
    background-color: #fff;
    /* border: #080 0px solid; - **EDITED** - doesn't seem like influences here */
    padding: 2px;
}

我需要显示以下HTML:

<table class="t_data">
    <thead style="padding:1px">
        <tr>
            <th>#</th>
            <th>Team</th>
            <th>Stadium Name</th>
            <th>Size</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>Team 1</td>
            <td>Name 1</td>
            <td>Size 1-1, 2-1, 3-1</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Team 1</td>
            <td>Name 1</td>
            <td>Size 1-1, 2-1, 3-1</td>
        </tr>
        <tr>
            <td>3</td>
            <td>Team 1</td>
            <td>Name 1</td>
            <td>Size 1-1, 2-1, 3-1</td>
        </tr>
    </tbody>
</table>

它在Mozilla Firefox和IE8中显示完美(如预期)表:

Mozilla table formatted

但其他浏览器/模式存在问题:

在Chrome中,头部和身体之间的线是双倍宽度:

Chrome table formatted

在IE8(切换到IE7兼容模式)中,所有行都是双倍宽度:

IE table formatted

问题:什么是CSS选项使每一行粗体相同(1px)?

1 个答案:

答案 0 :(得分:3)

 table.t_data { border-collapse:collapse }