有行与列合并的小案例表格

编辑: admin 分类: 电脑知识 发布时间: 2023-06-14 来源:互联网
先看图:

实例代码:
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>课程表</title>
  8. <style>
  9. thead{
  10. background-color: aquamarine;
  11. }
  12. tfoot{
  13. background-color: aliceblue;
  14. }
  15. td{
  16. text-align: center;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <table border="1px" align="center">
  22. <caption>课程表</caption>
  23. <thead>
  24. <tr>
  25. <th>名字</th>
  26. <th>课程</th>
  27. <th>练习时长</th>
  28. <th>天赋</th>
  29. <th>段位</th>
  30. <th>分数</th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. <tr>
  35. <td rowspan="4">ikun</td>
  36. <td>唱</td>
  37. <td rowspan="6">两年半</td>
  38. <td>25</td>
  39. <td>2.5</td>
  40. <td>5</td>
  41. </tr>
  42. <tr>
  43. <!-- <td>蔡徐坤</td> -->
  44. <td>跳</td>
  45. <!-- <td>10</td> -->
  46. <td>25</td>
  47. <td>2.5</td>
  48. <td>5</td>
  49. </tr>
  50. <tr>
  51. <!-- <td>蔡徐坤</td> -->
  52. <td>Rap</td>
  53. <!-- <td>10</td> -->
  54. <td>25</td>
  55. <td>2.5</td>
  56. <td>5</td>
  57. </tr>
  58. <tr>
  59. <!-- <td>ikun</td> -->
  60. <td>篮球</td>
  61. <!-- <td>10</td> -->
  62. <td>25</td>
  63. <td>2.5</td>
  64. <td>5</td>
  65. </tr>
  66. <tr>
  67. <td rowspan="2">ikun</td>
  68. <td>背带裤</td>
  69. <!-- <td>10</td> -->
  70. <td>-</td>
  71. <td>2.5</td>
  72. <td>-</td>
  73. </tr>
  74. <tr>
  75. <!-- <td>蔡徐坤</td> -->
  76. <td>中分</td>
  77. <!-- <td>10</td> -->
  78. <td>25</td>
  79. <td>-</td>
  80. <td>5</td>
  81. </tr>
  82. </tbody>
  83. <tfoot>
  84. <tr>
  85. <td colspan="4">合计</td>
  86. <!-- <td>合计</td>
  87. <td>合计</td>
  88. <td>合计</td> -->
  89. <td>半坤</td>
  90. <td>25</td>
  91. </tr>
  92. </tfoot>
  93. </table>
  94. </body>
  95. </html>

ps:

rowspan="" 属性为行合并,以当前行开始计算
colspan="" 属性为列合并,以当前列开始计算

【文章原创作者:香港云服务器 http://www.558idc.com/ne.html 复制请保留原URL】