Html 制作只有水平线的表格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20915841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:19:07  来源:igfitidea点击:

Making a table with horizontal line only

htmlcss

提问by aconstancio

How can I build a tablein HTML and CSS only with the horizontallines? I've tried so much stuff but I cant get it to work.

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

Something like this:

像这样的东西:

Name(space) Age

姓名(空格)年龄



Andre (space) 12

安德烈(空间)12



Jose (space) 16

何塞(空格)16



回答by Josh Beam

Potentially like this (jsfiddle):

可能像这样(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>

回答by Deatk

the css for the horizontal dividers is:

水平分隔线的 css 是:

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

see: https://www.w3schools.com/css/css_table.asp

见:https: //www.w3schools.com/css/css_table.asp