html ul li 左右两排_HTML,CSS篇:真·伪京东购物车

87dcecac-fc18-eb11-8da9-e4434bdf6706.png

本文只是个简单的小栗子,适合前端小白去熟悉,HTML,CSS。

HTML部分

<!DOCTYPE html>

有两个CSS文件

1.CSS常规设置

body,div,ul,h3,li{margin: 0px;padding: 0px;}
body{text-align: center;font-size: 10;}
a{text-decoration: none;}
li{list-style: none;}


2.CSS主体部分

.first_one {
	
	width: 1000px;
	height: 30px;
	background-color: ghostwhite;
	margin: 0 auto;
	
	/*border:1px solid green;*/
	
}
.first_one li{
	float: left;
	
}
.first_one a,.first_two a,.first_two span{
	line-height: 30px;
	color: grey;
font-size: 12px;
margin-left: 10px;
}
.first{
	
	width: 100%;
	height: 30px;
	background-color: ghostwhite;
}
.first_two{
	float: right;
	
}
a:hover{color: red;
text-decoration: underline;}


/*第二部分*/

.two{
	height: 60px;
	margin-left: 320px;
	margin-top: 30px;
	
}
.two img{
	float: left;
	
	
	
}
.two_one{
	float: right;
	margin-top: 25px;
	
	margin-right: 324px;
}
.two_text{
	width: 265px;
	height: 21px;
	border: 3px solid red;
	position: relative;
	left: 5px;
	top: -1px;
}
.two_bu{
	width: 51px;
	height: 29px;
	background-color: red;
	border: 0px;
	color: white;
}
/*第三段*/
.three{
	margin-left: 320px;
	margin-right: 324px;
	height: 30px;
}
.three_one h3{
	font-size: 23px;
	clear: both;
	float: left;
color: red;
}
.three_two{
	line-height: 30px;
	float: right;
	color: gainsboro;
	margin-top: 10px;
}
/*第四部分*/
.four{
	background-color: gainsboro;
	width: 1000px;
	height: 40px;
	margin-left: 320px;
	float: left;
}
.four li{
	float: left;
	font-size: 12px;
	color: gray;
	line-height: 40px;
	
}
.four li:nth-child(1){width: 90px;border-top: 3px solid red;}
.four li:nth-child(2){margin-left: 80px;}
.four li:nth-child(3){margin-left: 400px;}
.four li:nth-child(4){margin-left: 70px;}
.four li:nth-child(5){margin-left: 110px;}
.four li:nth-child(6){margin-left: 50px;}
/*第五部分*/
.five{
	clear: both;
	
	width: 1000px;
	height: 150px;
	margin-left: 320px;
	margin-top: 80px;
	border: 1px solid gray;
	background-color: #FFF4E8;	
	
	
	}
.five_one li{
	margin-top: 30px;
	float: left;
	font-size: 12px;
	color: black;
}
.five li:nth-child(1){width: 30px;}
.five li:nth-child(2){margin-left: 20px;}
.five li:nth-child(3){margin-left: 30px;}
.five li:nth-child(4){margin-left: 50px;}
.five li:nth-child(5){margin-left: 80px;}
.five li:nth-child(6){margin-left: 30px;}
.five li:nth-child(7){margin-left: 50px;}
.five li:nth-child(8){margin-left: 30px;}
.five input{width: 30px;position: relative;left:5px;text-align: center;}
.five_bu{position: relative;left:10px;}
.five a{color: black;}

.six{clear: both;
	
	width: 1000px;
	height: 150px;
	margin-left: 320px;
	margin-top: 30px;
	border: 1px solid gray;
	background-color: #FFF4E8;	
	
}
.six_one li{
	margin-top: 30px;
	float: left;
	font-size: 12px;
	color: black;
}
.six li:nth-child(1){width: 30px;}
.six li:nth-child(2){margin-left: 20px;}
.six li:nth-child(3){margin-left: 80px;}
.six li:nth-child(4){margin-left: 140px;}
.six li:nth-child(5){margin-left: 100px;}
.six li:nth-child(6){margin-left: 30px;}
.six li:nth-child(7){margin-left: 50px;}
.six li:nth-child(8){margin-left: 40px;}
.six input{width: 30px;position: relative;left:5px;text-align: center;}
.six_bu{position: relative;left:10px;}
.six a{color: black;}

/*第六半径*/
.seven{clear: both;
	
	width: 1000px;
	height: 60px;
	margin-left: 320px;
	margin-top: 30px;
	border: 1px solid gray;
	background-color: white;}
.seven li{
	float: left;
	margin-top: 20px;
	float: left;
	font-size: 12px;
	color: gray;
}
.seven li:nth-child(1){width: 10px;}
.seven li:nth-child(2){margin-left: 20px;}
.seven li:nth-child(3){margin-left: 20px;}
.seven li:nth-child(4){margin-left: 20px;}
.seven li:nth-child(5){margin-left: 60px;}
.seven li:nth-child(6){margin-left: 320px;position: relative;top:-10px;font-size: 14px;}
.seven li:nth-child(7){margin-left: 20px;position: relative;top:-10px;font-size: 14px;}
.seven li:nth-child(9){margin-left: 50px;position: relative;top:20px;right:140px;font-size: 14px;}
.seven li:nth-child(8){position: relative;top:-10px;font-size: 14px;}
/*第八部分*/
/*.eirht{
	
}*/
.eirht input{
	width: 114px;
	height: 61px;
	background-color: red;
	
	position: relative;
	top: -20px;
	left: 2px;
	clear: both;
	border: 1px solid red;
	float: right;
	font-size: 16px;
	color:white;
	text-align: center;
}

效果图是这样的

88dcecac-fc18-eb11-8da9-e4434bdf6706.png

关于页面功能的增加请等下次更新。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
创建一个HTMLCSS的简单购物车模拟器,你可以使用基本的HTML结构来构建页面布局,结合CSS来美化外观,使其类似小米商城的购物车。以下是一个基础示例: ```html <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>小米商城购物车模拟</title> <style> body { font-family: Arial, sans-serif; } .cart { background-color: #f7f7f7; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } .cart-header { display: flex; justify-content: space-between; align-items: center; } .cart-header h2 { margin: 0; } .cart-items { list-style-type: none; padding: 0; } .item { display: flex; margin-bottom: 15px; } .item img { width: 50px; height: 50px; margin-right: 10px; } .item-name, .item-price { font-weight: bold; } .cart-footer { text-align: right; } </style> </head> <body> <div class="cart"> <div class="cart-header"> <h2>我的购物车</h2> <a href="#" class="cart-empty">清空购物车</a> </div> <ul class="cart-items"> <!-- 添加商品项 --> <li class="item"> <img src="product1.jpg" alt="产品1"> <span class="item-name">产品1</span> <span class="item-price">¥199.00</span> <button class="remove-item">移除</button> </li> <!-- 添加更多商品项 --> </ul> <div class="cart-footer"> <p>总计:¥<span id="total-price">0.00</span></p> </div> </div> <script> // 假设这里有一个数组存储购物车商品数据,需要添加计算总价格的逻辑 const cartItems = [ { name: '产品1', price: 199 }, { name: '产品2', price: 299 }, // ... ]; // 在此处编写代码,动态渲染商品并计算总价 function renderCart() { let totalPrice = 0; cartItems.forEach(item => { totalPrice += item.price; const li = document.createElement('li'); li.classList.add('item'); li.innerHTML = ` <img src="${item.image}" alt="${item.name}"> <span class="item-name">${item.name}</span> <span class="item-price">¥${item.price}</span> <button class="remove-item">移除</button> `; li.querySelector('.remove-item').addEventListener('click', () => { // 移除商品逻辑 }); document.querySelector('.cart-items').appendChild(li); }); document.getElementById('total-price').textContent = totalPrice; } renderCart(); </script> </body> </html> ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值