<table> <thead> <tr> <th>关系</th> <th>姓名</th> <th>备注</th> </tr> </thead> <tbody> <tr> <td>父亲</td> <td>李乾</td> <td>即李敬[24]</td> </tr> <tr> <td>母亲</td> <td>婴敷</td> <td>益寿氏[24]</td> </tr> <tr> <td>儿子</td> <td>李宗</td> <td>为魏将,封于段干[25]</td> </tr> <tr> <td>孙子</td> <td>李注</td> <td>[25]</td> </tr> <tr> <td>曾孙</td> <td>李宫</td> <td>[25]</td> </tr> </tbody> </table>设置css样式
时间: 2023-07-09 08:18:19 浏览: 183
漂亮的table样式(内附css)
5星 · 资源好评率100%
以下是使用 CSS 样式美化表格的代码:
```html
<style>
table {
border-collapse: collapse;
width: 100%;
margin-bottom: 20px;
}
th, td {
text-align: left;
padding: 8px;
border: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
</style>
<table>
<thead>
<tr>
<th>关系</th>
<th>姓名</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>父亲</td>
<td>李乾</td>
<td>即李敬[24]</td>
</tr>
<tr>
<td>母亲</td>
<td>婴敷</td>
<td>益寿氏[24]</td>
</tr>
<tr>
<td>儿子</td>
<td>李宗</td>
<td>为魏将,封于段干[25]</td>
</tr>
<tr>
<td>孙子</td>
<td>李注</td>
<td>[25]</td>
</tr>
<tr>
<td>曾孙</td>
<td>李宫</td>
<td>[25]</td>
</tr>
</tbody>
</table>
```
效果如下:
<style>
table {
border-collapse: collapse;
width: 100%;
margin-bottom: 20px;
}
th, td {
text-align: left;
padding: 8px;
border: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
</style>
<table>
<thead>
<tr>
<th>关系</th>
<th>姓名</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>父亲</td>
<td>李乾</td>
<td>即李敬[24]</td>
</tr>
<tr>
<td>母亲</td>
<td>婴敷</td>
<td>益寿氏[24]</td>
</tr>
<tr>
<td>儿子</td>
<td>李宗</td>
<td>为魏将,封于段干[25]</td>
</tr>
<tr>
<td>孙子</td>
<td>李注</td>
<td>[25]</td>
</tr>
<tr>
<td>曾孙</td>
<td>李宫</td>
<td>[25]</td>
</tr>
</tbody>
</table>
阅读全文