html购物车页面

今天博主给大家分享一个自己做的购物车页面,使用的是html+css实现:
话不多说,直接上图:
在这里插入图片描述
这个页面只是实现了其布局视图,没有使用js或者jquery相关语言,在博主看来是比较利于我们将其加入到自己的程序中的
以下是相关代码:
index.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link href="css/car.css" rel="stylesheet" type="text/css">
		<title></title>
	</head>
	<body>
		<div class="car">
			
				<div class="good">
					<table><tr><td width=30%>商品名称</td><td width=20%>单价</td><td width=20%>数量</td><td width=30%>操作</td></tr></table>
				</div>
				<div class="goods">
					<table><tr><td width=30%>旁氏洗发露</td><td width=20%>99</td><td width=20%>1</td><td width=30%><a><button class="btn1">删除</button></a></td></tr></table>
				</div>
				<div class="goods">
					<table><tr><td width=30%>旁氏洗发露</td><td width=20%>99</td><td width=20%>1</td><td width=30%><a><button class="btn1">删除</button></a></td></tr></table>
				</div>
				<div class="goods2">
					<table><tr><td width=560></td><td width=20%>小计:</td><td>总数:</td></tr></table>
				</div>
				<div class="goods1">
					<table><tr><td width=50%><button class="btn2">确认购买</button></td><td><button class="btn3">全部清空</button></td></tr></table>
				</div>
			
		</div>
	</body>
</html>

car.css

body{
	overflow: hidden;
	text-align: center;
	
}
.car{
	width:60%;
	border: 1px solid #F88020;
	border-radius: 18px;
	margin-left: 300px;
	
	
}
.car .good{
	background-color: #F88020;
	height:55px;
	font-size: 22px;
	color:white;
	line-height: 55px;
	font-weight: 200;
	border-radius: 18px 18px 0 0;
	margin-bottom: 20px;
	
}
.car .good table{
	width:100%;
}
.car .goods{
	height:45px;
	line-height: 45px;
	font-size: 20px;
	font-weight: 200;
}
.car .goods table{
	width:100%;
}
.car .goods table .btn1{
	width: 70px;
	height:28px;
	border: 2px solid #46B3E6;
	background-color: white;
	color: #46B3E6;
	border-radius: 4px;
	font-weight: 600;
}
.car .goods table button:hover{
	background-color: #46B3E6;
	color: white;
}
.car .goods1{
	margin-top: 10px;
	
	background-color: ;
	height:50px;
	font-size: 19px;
	color:white;
	line-height: 50px;
	font-weight: 200;
	border-radius:0 0 10px 10px ;
}
.car .goods2{
	border-top: 1px solid #F88020;
	margin-top: 10px;
	height:50px;
	font-size: 19px;
	line-height: 50px;
	font-weight: 200;
	border-radius:0 0 10px 10px ;
}
.car .goods1 table{
	
	width:100%;
}
.car .goods1 .btn2{
	width: 70px;
	height:28px;
	border: 2px solid #21BF73;
	background-color: white;
	color: #21BF73;
	border-radius: 4px;
	font-weight: 600;
}
.car .goods1 .btn2:hover{
	color:white;
	background-color: #21BF73;
}
.car .goods1 .btn3{
	width: 80px;
	height:30px;
	border: 2px solid #FF0000;
	background-color: white;
	color: #FF0000;
	border-radius: 4px;
	font-weight: 600;
}
.car .goods1 .btn3:hover{
	color:white;
	background-color:#FF0000 ;
}

码字不易给个赞呗

  • 111
    点赞
  • 259
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 12
    评论
假设你已经有了一个 HTML 购物车页面,其中包含了用户选择的商品信息和数量。现在需要将这些信息显示在订单页面上,可以使用 JavaScript 来实现。 首先,在订单页面上创建一个空的表格来显示购物车中的商品信息和数量: ```html <table id="cart-table"> <thead> <tr> <th>商品名称</th> <th>数量</th> </tr> </thead> <tbody> </tbody> </table> ``` 然后,在 JavaScript 中获取购物车页面中的商品信息和数量,并将其添加到订单页面的表格中: ```javascript // 获取购物车页面中的商品信息和数量 var cartItems = document.querySelectorAll('.cart-item'); var cartTable = document.querySelector('#cart-table tbody'); for (var i = 0; i < cartItems.length; i++) { var itemName = cartItems[i].querySelector('.item-name').textContent; var itemQuantity = cartItems[i].querySelector('.item-quantity').textContent; // 将商品信息和数量添加到订单页面的表格中 var row = document.createElement('tr'); var nameCell = document.createElement('td'); nameCell.textContent = itemName; var quantityCell = document.createElement('td'); quantityCell.textContent = itemQuantity; row.appendChild(nameCell); row.appendChild(quantityCell); cartTable.appendChild(row); } ``` 在上述代码中,我们首先使用 `document.querySelectorAll()` 方法获取购物车页面中所有的商品信息和数量,然后使用 `document.querySelector()` 方法获取订单页面中的表格。接着,使用 `for` 循环遍历每个购物车商品,获取商品名称和数量,并将其添加到订单页面的表格中。 需要注意的是,在购物车页面中获取商品信息和数量的方法可能会因为具体的 HTML 结构而有所不同,上述代码仅供参考。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

彭祥.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值