首页 > 解决方案 > 使用 CSS 制作响应式表格

问题描述

我有一个表格来表示 html 页面中的一些数据。我试图让这个表格通过 CSS 响应。

<table>
    <tr>
        <thead>
            <th>Name</th>
            <th>Age</th>
            <th>Tell</th>
        </thead>
        <tbody>
            <tr>
                <td>Maya</td>
                <td>22</td>
                <td>2222555666</td>
            </tr>
        </tbody>
    </tr>
</table>

我以前是这样做的:

table thead {display:none}
table tr, table td{display:block}
table td:nth-of-type(1)::before {content: "Name";}

有一个问题,当我知道有多少<td></td>和内容<th></th>是什么时,这种方式会很有帮助,但在这种情况下,我不知道的数量<td></td>和内容<th></th>?我能做些什么?

标签: htmlcss

解决方案


推荐阅读