Blogger Information
Blog 28
fans 0
comment 1
visits 21322
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
完成一个购物车(表格实现)
南宫
Original
693 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. html{
  9. /* 所有字号 */
  10. font-size: 14px;
  11. }
  12. table{
  13. /* 将单元格之间的间隙去掉 会忽略 border-spacing 和 empty-cells 属性*/
  14. border-collapse: collapse;
  15. width: 70%;
  16. /* 水平居中 */
  17. margin: auto;
  18. color: #666;
  19. /* 定义更细的字符 */
  20. font-weight: lighter;
  21. text-align: center;
  22. }
  23. /* 表格线直接添加到单元格上面 */
  24. table thead th,
  25. table td{
  26. border-bottom: 1px solid #ccc;
  27. padding: 10px;
  28. }
  29. /* 标题样式 */
  30. table caption{
  31. font-size: 1.5rem;
  32. margin-bottom: 15px;
  33. color: green;
  34. }
  35. table th{
  36. font-weight: lighter;
  37. color: green;
  38. }
  39. table thead tr{
  40. background-color: cyan;
  41. }
  42. /* 隔行变色 也可以用:nth-of-type(even) */
  43. table tbody tr:nth-child(even){
  44. background-color: yellow;
  45. }
  46. /* 鼠标悬停效果 */
  47. table tbody tr:hover{
  48. background-color: pink;
  49. }
  50. /* 底部样式 */
  51. table tfoot td{
  52. /* 去掉底部边框 */
  53. border-bottom: none;
  54. color: coral;
  55. font-size: 1.2rem;
  56. /* 字体加粗 */
  57. font-weight: bolder;
  58. }
  59. /* 结算按钮 */
  60. /* body div:last-of-type{
  61. width: 70%;
  62. margin: 10px auto;
  63. } */
  64. body div:first-of-type button{
  65. /* 靠右 */
  66. float: right;
  67. width: 120px;
  68. height: 32px;
  69. background-color: seagreen;
  70. color: white;
  71. border: none;
  72. /* 设置鼠标样式 小手 */
  73. cursor: pointer;
  74. }
  75. /* 鼠标悬停时样式 */
  76. body div:first-of-type button:hover{
  77. background-color: coral;
  78. font-size: 1.1rem;
  79. }
  80. </style>
  81. </head>
  82. <body>
  83. <!-- 表格 -->
  84. <table>
  85. <!-- 标题 -->
  86. <caption>
  87. 购物车
  88. </caption>
  89. <!-- 头部 -->
  90. <thead>
  91. <tr>
  92. <th>ID</th>
  93. <th>品名</th>
  94. <th>单价(元)</th>
  95. <th>单位</th>
  96. <th>数量</th>
  97. <th>金额(元)</th>
  98. </tr>
  99. </thead>
  100. <!-- 主体 -->
  101. <tbody>
  102. <tr>
  103. <td>SN-1001</td>
  104. <td>MacBook Pro电脑</td>
  105. <td>18999</td>
  106. <td></td>
  107. <td>1</td>
  108. <td>18999</td>
  109. </tr>
  110. <tr>
  111. <td>SN-1002</td>
  112. <td>iPhone XS</td>
  113. <td>4999</td>
  114. <td></td>
  115. <td>2</td>
  116. <td>9998</td>
  117. </tr>
  118. <tr>
  119. <td>SN-1003</td>
  120. <td>小米音响</td>
  121. <td>399</td>
  122. <td></td>
  123. <td>5</td>
  124. <td>1995</td>
  125. </tr>
  126. <tr>
  127. <td>SN-1004</td>
  128. <td>128G三星固态移动硬盘</td>
  129. <td>245</td>
  130. <td></td>
  131. <td>2</td>
  132. <td>490</td>
  133. </tr>
  134. <tr>
  135. <td>SN-1005</td>
  136. <td>格力空调1.5匹</td>
  137. <td>3020</td>
  138. <td></td>
  139. <td>1</td>
  140. <td>3020</td>
  141. </tr>
  142. </tbody>
  143. <!-- 底部 -->
  144. <tfoot>
  145. <tr>
  146. <td colspan="4">总计:</td>
  147. <td>11</td>
  148. <td>34502</td>
  149. </tr>
  150. </tfoot>
  151. <!-- 结算按钮 -->
  152. <div>
  153. <button>结算</button>
  154. </div>
  155. </table>
  156. </body>
  157. </html>

Correcting teacher:GuanhuiGuanhui

Correction status:qualified

Teacher's comments:可以加些文字描述一下代码!
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post