购物车结算页面的编写
1.首先将购物车大概的布局想象出来,尽量画出来,或者参照有个现有的界面进行模仿
2.按照布局内容编写HTML代码
3.用CSS进行排版和样式改变
以下是效果图:
以下是HTML代码和CSS代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>仿京东商城购物车结算页面</title>
<style>
/*初始化*/
* :not(body){
padding: 0;
margin: 0;
/*outline: 1px dashed red;*/
font-size: 13px;
}
a {
text-decoration: none;
color: black;
font-size: 13px
}
ul,li {
list-style: none;
}
img {
width: 100%;
}
/*header的布局*/
header {
height: 30px;
display: flex;
justify-content: space-between;
background-color: #cccccc;
}
header > .item1 {
padding: 5px 10px;
box-sizing: border-box;
margin-left: 200px;
}
header > .item2 {
padding: 5px 10px;
box-sizing: border-box;
margin-right: 200px;
}
header span {
padding: 0 5px;
}
header > .item2 > a > span:hover {
color: red;
}
/*LOGO+search布局*/
.title {
display: flex;
height: 100px;
justify-content: space-between;
}
.title > .logo {
margin-left: 200px;
align-self: center;
}
.title > .logo > a > img {
width: 100px;
height: 80px;
}
.title > .logo > span {
font-size: 20px;
padding-left: 10px;
}
.title > .search {
margin-right: 200px;
align-self: center;
display: flex;
}
.title > .search > input {
width: 300px;
height: 30px;
border: 3px solid red;
}
.title > .search > label {
height: 30px;
width: 50px;
background-color: red;
color: white;
text-align: center;
line-height: 30px;
}
/*购物车详情布局---上部分*/
.shopping-cart {
width: 940px;
margin: auto;
display: flex;
flex-direction: column;
}
.shopping-cart > .detail {
height: 40px;
display: flex;
text-align: center;
line-height: 40px;
justify-content: space-between;
background-color: #cccccc;
border: 1px solid black;
}
.shopping-cart > .detail > .detail1 {
margin-left: 10px;
}
.shopping-cart > .detail > .detail1 > span {
margin-left: 50px;
}
.shopping-cart > .detail > .detail2 {
margin-right: 100px;
}
.shopping-cart > .detail > .detail2 > span {
margin: 0 50px;
}
/*购物车详情布局---下部分*/
.shopping-cart > .shop-list {
height: 80px;
display: flex;
margin-left: 10px;
justify-content: space-around;
}
.shopping-cart > .shop-list input:first-of-type {
position: relative;
left: -35px;
}
.shopping-cart > .shop-list img {
height: 50px;
width: 50px;
position: relative;
left: -70px;
display: block;
top:20px;
}
.shopping-cart > .shop-list span:first-of-type {
width: 200px;
position: relative;
left: -140px;
align-self: center;
}
.shopping-cart > .shop-list span:nth-of-type(2){
position: relative;
left: -160px;
align-self: center;
}
.shopping-cart > .shop-list input:last-of-type {
position: relative;
left: -150px;
width: 50px;
height: 20px;
align-self: center;
}
.shopping-cart > .shop-list span:nth-of-type(3){
position: relative;
left: -140px;
align-self: center;
}
.shopping-cart > .shop-list span:last-of-type {
position: relative;
left: -115px;
align-self: center;
}
footer {
width: 940px;
margin: auto;
display: flex;
justify-content: flex-end;
border-top: 1px solid black;
}
footer > .end {
height: 60px;
margin-right: 140px;
}
footer > .end > button {
width: 100px;
height: 60px;
background-color: red;
color: #cccccc;
font-size: 20px;
font-weight: bold;
}
footer > .end > span {
padding: 0 10px;
}
footer > .end > span:last-of-type {
font-weight: bold;
color: red;
}
</style>
</head>
<body>
<header>
<div class="item1">
<a href=""><span>京东首页</span></a>
<a href=""><span>四川</span></a>
</div>
<div class="item2">
<a href=""><span>我的订单</span></a>
<a href=""><span>我在京东</span></a>
<a href=""><span>京东会员</span></a>
<a href=""><span>企业采购</span></a>
<a href=""><span>客户服务</span></a>
<a href=""><span>网站导航</span></a>
<a href=""><span>手机京东</span></a>
</div>
</header>
<div class="title">
<div class="logo">
<a href=""><img src="static/images/logo.png" alt=""></a>
<span>购物车</span>
</div>
<div class="search">
<input type="search" id="search" value="自营"><label for="search">搜索</label>
</div>
</div>
<div class="shopping-cart">
<div class="detail">
<div class="detail1">
<input type="checkbox" id="checkbox" checked><label for="checkbox">全选</label>
<span>商品</span>
</div>
<div class="detail2">
<span>单价</span>
<span>数量</span>
<span>小计</span>
<span>操作</span>
</div>
</div>
<div class="shop-list">
<input type="checkbox" checked>
<a href=""><img src="static/images/ad/1.png" alt=""></a>
<span>PHP中文网是最良心网站PHP中文网是最良心网站</span>
<span>¥1488</span>
<input type="number" value="1">
<span>¥1488</span>
<span>删除</span>
</div>
<div class="shop-list">
<input type="checkbox" checked>
<a href=""><img src="static/images/ad/1.png" alt=""></a>
<span>PHP中文网是最良心网站PHP中文网是最良心网站</span>
<span>¥1488</span>
<input type="number" value="1">
<span>¥1488</span>
<span>删除</span>
</div>
<div class="shop-list">
<input type="checkbox" checked>
<a href=""><img src="static/images/ad/1.png" alt=""></a>
<span>PHP中文网是最良心网站PHP中文网是最良心网站</span>
<span>¥1488</span>
<input type="number" value="1">
<span>¥1488</span>
<span>删除</span>
</div>
</div>
<footer>
<div class="end">
<span>总价</span>
<span>¥20000</span>
<button>去结算</button>
</div>
</footer>
</body>
</html>