html – 表格行未扩展到全宽

前端之家收集整理的这篇文章主要介绍了html – 表格行未扩展到全宽前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个表,当我将表设置为100%的宽度和表行宽度pf 100%没有任何反应或更改宽度。
.Table-Normal {
    position: relative;
    display: block;
    margin: 10px auto;
    padding: 0;
    width: 100%;
    height: auto;
    border-collapse: collapse;
    text-align: center;
}

.Table-Normal thead tr {
    background-color: #E74C3C;
    font-weight: bold;
}

.Table-Normal tr {
    margin: 0;
    padding: 0;
    border: 0;
    border: 1px solid #999;
    width: 100%;
}

.Table-Normal tr td {
    margin: 0;
    padding: 4px 8px;
    border: 0;
    border: 1px solid #999;
}

.Table-Normal tbody tr:nth-child(2) {
    background-color: #EEE;
}
<table id="top-leader" class="Table-Normal">
    <thead>
        <tr>
            <td>Position</td>
            <td>Name</td>
            <td>Kills</td>
            <td>Deaths</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>John Doe</td>
            <td>16 Kills</td>
            <td>0 Deaths</td>
        </tr>

        <tr>
            <td>2</td>
            <td>John Smith</td>
            <td>13 Kils</td>
            <td>1 Death</td>
        </tr>

        <tr>
            <td>3</td>
            <td>Bob Smith</td>
            <td>11 Kills</td>
            <td>0 Deaths</td>
        </tr>
    </tbody>
</table>

解决方法

删除display:block in .Table-Normal

Fiddle

.Table-Normal {
    position: relative;
    //display: block;
    margin: 10px auto;
    padding: 0;
    width: 100%;
    height: auto;
    border-collapse: collapse;
    text-align: center;
}

猜你在找的HTML相关文章