在网页设计中,表格是很重要的一部分。而对表格的定位,CSS的作用就显得尤为重要。以下是一些关于在CSS中表格定位的技巧。 首先,要让表格居中。这可以通过设置table的margin属性为"0...
在网页设计中,表格是很重要的一部分。而对表格的定位,CSS的作用就显得尤为重要。以下是一些关于在CSS中表格定位的技巧。
首先,要让表格居中。这可以通过设置table的margin属性为"0 auto"来实现。
p {
font-size: 16px;
line-height: 1.5;
}
<br>
table {
margin: 0 auto;
} table {
width: 100%;
} table {
table-layout: fixed;
}
<br>
th, td {
width: 100px;
} table {
border: 1px solid #ccc;
border-collapse: collapse;
}
<br>
th, td {
border: 1px solid #ccc;
padding: 5px;
} tr:nth-child(even) {
background-color: #f2f2f2;
}
<br>
td:hover {
background-color: #ccc;
}