实例
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>表格</title> <style> table { width: 600px; margin: 10px auto; border: solid 1px #333; /*-webkit-border-radius: 15px;*/ /*-moz-border-radius: 15px;*/ border-collapse: collapse; } table caption { margin-bottom: 10px; font-weight: bolder; font-size: 1.2rem; } th, td { border: solid 1px #333; text-align: center; padding: 10px; } table>thead:nth-of-type(1) { background-color: lightgreen; } table tbody>tr:first-of-type>td:first-of-type { background-color: lightcoral; } table tbody>tr:nth-of-type(4)>td:first-of-type { background-color: blueviolet; } table tfoot>tr:first-child { background-color: #ccc; } </style> </head> <body> <table> <caption>学生课程表</caption> <thead> <th>星期</th> <th>星期一</th> <th>星期二</th> <th>星期三</th> <th>星期四</th> <th>星期四</th> </thead> <tbody> <tr> <td rowspan="3">上午 8:00-11:00</td> <td>语文</td> <td>数学</td> <td>美术</td> <td>体育</td> <td>音乐</td> </tr> <tr> <td>语文</td> <td>数学</td> <td>美术</td> <td>体育</td> <td>音乐</td> </tr> <tr> <td>语文</td> <td>数学</td> <td>美术</td> <td>体育</td> <td>音乐</td> </tr> <tr> <td rowspan="2">下午 3:00-5:00</td> <td>语文</td> <td>数学</td> <td>美术</td> <td>体育</td> <td>音乐</td> </tr> <tr> <td>语文</td> <td>数学</td> <td>美术</td> <td>体育</td> <td>音乐</td> </tr> </tbody> <tfoot> <tr> <td>备注:</td> <td colspan="5">放学打扫卫生</td> </tr> </tfoot> </table> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
效果如下图