<!DOCTYPE html>
<html>
<head>
<title>My Table Style</title>
<style>
table {
font-family: Arial, sans-serif;
border-collapse: collapse;
width: 100%;
border: 1px solid #ddd;
}
th, td {
text-align: left;
padding: 8px;
border: 1px solid #ddd;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
th {
background-color: #4CAF50;
color: white;
}
caption {
font-weight: bold;
font-size: 1.2em;
padding: 10px;
background-color: #ddd;
border: 1px solid #ddd;
}
</style>
</head>
<body>
<table>
<caption>My Table</caption>
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
<td>Row 1, Cell 3</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
<td>Row 2, Cell 3</td>
</tr>
<tr>
<td>Row 3, Cell 1</td>
<td>Row 3, Cell 2</td>
<td>Row 3, Cell 3</td>
</tr>
</tbody>
</table>
</body>
</html>
在这个样式中,表格具有以下特点:
- 字体使用 Arial 和 sans-serif 字体。
- 表格边框合并,宽度占据 100%。
- 表头和表格内容单元格具有统一的样式和间距。
- 奇数行背景颜色为 #f2f2f2。
- 表头背景颜色为 #4CAF50,字体颜色为白色。
- 表格标题具有粗体和大字体样式,带有背景颜色和边框。
你可以将这个样式应用到你的 HTML table 中,或者根据需要进行修改和定制。