案例
简单的表格
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"
rel="stylesheet"
/>
<title>Table component</title>
<style type="text/css">
/*
SPACING SYSTEM (px)
2 / 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 / 80 / 96 / 128
FONT SIZE SYSTEM (px)
10 / 12 / 14 / 16 / 18 / 20 / 24 / 30 / 36 / 44 / 52 / 62 / 74 / 86 / 98
*/
/*
主色:#087f5b
字体:#343a40
*/
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Inter", "Microsoft YaHei";
color: #495057;
line-height: 1;
}
table {
width: 800px;
margin: 100px auto;
/* border: 1px solid #343a40; */
border-collapse: collapse;
}
thead tr {
background-color: #087f5b;
color: #fff;
}
thead td {
width: 25%;
}
tbody tr:nth-child(odd) {
background-color: #f8f9fa;
}
tbody tr:nth-child(even) {
background-color: #e9ecef;
}
th,
td {
/* border: 1px solid #343a40; */
padding: 16px 24px;
text-align: left;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Chair</th>
<th>The Laid back</th>
<th>The Worker Bee</th>
<th>The Chair 4/2</th>
</tr>
</thead>
<tbody>
<tr>
<th>Width</th>
<td>80 cm</td>
<td>60 cm</td>
<td>220 cm</td>
</tr>
<tr>
<th>Height</th>
<td>100 cm</td>
<td>110 cm</td>
<td>90 cm</td>
</tr>
<tr>
<th>Depth</th>
<td>70 cm</td>
<td>65 cm</td>
<td>80 cm</td>
</tr>
<tr>
<th>Weight</th>
<td>16 kg</td>
<td>22 kg</td>
<td>80 kg</td>
</tr>
</tbody>
</table>
</body>
</html>