CSS是前端开发的基础技能之一,它能够为网页提供精美的样式效果。其中,表格是一种十分常见的网页元素,下面就来介绍一下如何利用CSS使表格更加美观。首先,我们需要在HTML文档中制作一个基本的表格结构,...
CSS是前端开发的基础技能之一,它能够为网页提供精美的样式效果。其中,表格是一种十分常见的网页元素,下面就来介绍一下如何利用CSS使表格更加美观。
首先,我们需要在HTML文档中制作一个基本的表格结构,例如:
<table>
<tr>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
</tr>
<tr>
<td>小明</td>
<td>20</td>
<td>男</td>
</tr>
<tr>
<td>小红</td>
<td>22</td>
<td>女</td>
</tr>
</table> table {
border-collapse: collapse;
background-color: #e6e6e6;
color: blue;
}
th, td {
border: 1px solid black;
} table {
width: 80%;
} tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #cceeff;
}