html写一个购物车页面
时间: 2023-12-16 07:04:30 浏览: 42
好的,以下是一个简单的购物车页面的HTML代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>购物车</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
table {
border-collapse: collapse;
margin: 20px auto;
width: 80%;
}
th, td {
border: 1px solid #ccc;
padding: 10px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
.total {
font-size: 24px;
font-weight: bold;
margin: 20px auto;
text-align: right;
width: 80%;
}
.checkout {
background-color: #4CAF50;
border: none;
color: #fff;
cursor: pointer;
font-size: 16px;
margin: 20px auto;
padding: 10px 20px;
text-align: center;
text-decoration: none;
width: 80%;
}
.checkout:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<header>
<h1>购物车</h1>
</header>
<table>
<thead>
<tr>
<th>商品名称</th>
<th>单价</th>
<th>数量</th>
<th>小计</th>
</tr>
</thead>
<tbody>
<tr>
<td>商品1</td>
<td>100</td>
<td>2</td>
<td>200</td>
</tr>
<tr>
<td>商品2</td>
<td>50</td>
<td>3</td>
<td>150</td>
</tr>
</tbody>
</table>
<div class="total">
总计:350元
</div>
<a href="#" class="checkout">去结算</a>
</body>
</html>
```
这个购物车页面包括一个表格,其中列出了商品名称、单价、数量和小计。最下方有一个显示总计的区域,并且提供一个链接用于结算。你可以根据自己的需求进行修改和完善。