制作一个只有水平线的桌子

时间:2014-01-04 01:51:36

标签: html css

如何仅使用水平行在HTML和CSS中构建table?我已经尝试了很多东西,但我无法让它发挥作用。

这样的事情:

名称(空格)年龄


安德烈(太空)12


何塞(太空)16


2 个答案:

答案 0 :(得分:18)

可能是这样的(jsfiddle):

table {
    border-collapse: collapse;
    width: 100%;
}

tr {
    border-bottom: 1px solid #ccc;
}

th {
    text-align: left;    
}

<table>
    <thead>
        <tr>
            <th>Name</th>
            <th>Age</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Jose</td>
            <td>25</td>
        </tr>
        <tr>
            <td>Alberto</td>
            <td>32</td>
        </tr>
    </tbody>
</table>

答案 1 :(得分:1)

水平分隔线的css是:

th, td {
  border-bottom: 1px solid #ddd;
}

请参阅:https://www.w3schools.com/css/css_table.asp

相关问题