Correcting teacher:Guanhui
Correction status:qualified
Teacher's comments:可以加些文字描述一下代码!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html{
/* 所有字号 */
font-size: 14px;
}
table{
/* 将单元格之间的间隙去掉 会忽略 border-spacing 和 empty-cells 属性*/
border-collapse: collapse;
width: 70%;
/* 水平居中 */
margin: auto;
color: #666;
/* 定义更细的字符 */
font-weight: lighter;
text-align: center;
}
/* 表格线直接添加到单元格上面 */
table thead th,
table td{
border-bottom: 1px solid #ccc;
padding: 10px;
}
/* 标题样式 */
table caption{
font-size: 1.5rem;
margin-bottom: 15px;
color: green;
}
table th{
font-weight: lighter;
color: green;
}
table thead tr{
background-color: cyan;
}
/* 隔行变色 也可以用:nth-of-type(even) */
table tbody tr:nth-child(even){
background-color: yellow;
}
/* 鼠标悬停效果 */
table tbody tr:hover{
background-color: pink;
}
/* 底部样式 */
table tfoot td{
/* 去掉底部边框 */
border-bottom: none;
color: coral;
font-size: 1.2rem;
/* 字体加粗 */
font-weight: bolder;
}
/* 结算按钮 */
/* body div:last-of-type{
width: 70%;
margin: 10px auto;
} */
body div:first-of-type button{
/* 靠右 */
float: right;
width: 120px;
height: 32px;
background-color: seagreen;
color: white;
border: none;
/* 设置鼠标样式 小手 */
cursor: pointer;
}
/* 鼠标悬停时样式 */
body div:first-of-type button:hover{
background-color: coral;
font-size: 1.1rem;
}
</style>
</head>
<body>
<!-- 表格 -->
<table>
<!-- 标题 -->
<caption>
购物车
</caption>
<!-- 头部 -->
<thead>
<tr>
<th>ID</th>
<th>品名</th>
<th>单价(元)</th>
<th>单位</th>
<th>数量</th>
<th>金额(元)</th>
</tr>
</thead>
<!-- 主体 -->
<tbody>
<tr>
<td>SN-1001</td>
<td>MacBook Pro电脑</td>
<td>18999</td>
<td>台</td>
<td>1</td>
<td>18999</td>
</tr>
<tr>
<td>SN-1002</td>
<td>iPhone XS</td>
<td>4999</td>
<td>部</td>
<td>2</td>
<td>9998</td>
</tr>
<tr>
<td>SN-1003</td>
<td>小米音响</td>
<td>399</td>
<td>台</td>
<td>5</td>
<td>1995</td>
</tr>
<tr>
<td>SN-1004</td>
<td>128G三星固态移动硬盘</td>
<td>245</td>
<td>个</td>
<td>2</td>
<td>490</td>
</tr>
<tr>
<td>SN-1005</td>
<td>格力空调1.5匹</td>
<td>3020</td>
<td>台</td>
<td>1</td>
<td>3020</td>
</tr>
</tbody>
<!-- 底部 -->
<tfoot>
<tr>
<td colspan="4">总计:</td>
<td>11</td>
<td>34502</td>
</tr>
</tfoot>
<!-- 结算按钮 -->
<div>
<button>结算</button>
</div>
</table>
</body>
</html>