布局代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./7张布局.css">
</head>
<body>
<nav>
<h2>人气推荐</h2>
<a href="" class="a">编辑推荐</a>
<a href="" class="aa">热销总榜</a>
<a href="" class="aaa">更多推荐></a>
<div class="seven_images">
<div class="seven_image1">
<div>
<img src="./猫粮.jpg" alt="" width="390px" height="400px">
</div>
<div>
<p>
<span>限时购</span>
</p>
<p>
<span>每一口都有七种肉,全价猫粮 <br> 1.8千克</span>
</p>
<p>
<span>¥78</span>
<span>¥88</span>
</p>
</div>
</div>
<div class="seven_image2">
<div>
<div>
<img src="./洗衣液.jpg" alt="" width="223px" height="180px">
</div>
<div>
<p>
<span>限时购</span>
<span>满赠</span>
</p>
<p>
<span>清新英国梨香 强力去污 <br> 酵素洗衣液3kg/1kg</span>
</p>
<p>
<span>¥29.9</span>
<span>¥35</span>
</p>
</div>
</div>
<div>
<div>
<img src="./凤爪.jpg" alt="" width="223px" height="180px">
</div>
<div>
<p>
<span>新人特价</span>
</p>
<p>
<span>告别啃食尴尬,秘制无 <br>骨凤爪108克</span>
</p>
<p>
<span>¥13</span>
<span>¥22</span>
</p>
</div>
</div>
</div>
<div class="seven_image2">
<div>
<div>
<img src="./拖鞋.jpg" alt="" width="223px" height="180px">
</div>
<div>
<p>
<span>新人特价</span>
</p>
<p>
<span>轻弹云朵居家拖鞋</span>
</p>
<p>
<span>¥9.9</span>
<span></span>
</p>
</div>
</div>
<div>
<div>
<img src="./学步裤.jpg" alt="" width="223px" height="180px">
</div>
<div>
<p>
<span>杭州制造</span>
<span>特价</span>
</p>
<p>
<span>薄至2.5mm,海量鲸 <br>吸婴儿拉拉裤学步裤</span>
</p>
<p>
<span>¥59</span>
<span>¥69</span>
</p>
</div>
</div>
</div>
<div class="seven_image2">
<div>
<div>
<img src="./口罩.jpg" alt="" width="223px" height="180px">
</div>
<div>
<p>
<span>浙江制造</span>
<span>新人特价</span>
</p>
<p>
<span>【限量抢购中】一次性 <br>医用级三层口罩</span>
</p>
<p>
<span>¥20</span>
<span>¥139</span>
</p>
</div>
</div>
<div>
<div>
<img src="./棉被.jpg" alt="" width="223px" height="180px">
</div>
<div>
<p>
<span>2件3折</span>
</p>
<p>
<span>软软暖暖入睡 澳大利亚 <br>防水羊毛床垫</span>
</p>
<p>
<span>¥20</span>
<span></span>
</p>
</div>
</div>
</div>
</div>
</nav>
</body>
</html>
样式代码:
nav{
width: 1519.2px;
height: 738px;
background-color: #f4f0ea;
margin: 0 auto;
}
nav h2{
width: 112px;
height: 28px;
font-size: 28px;
font-weight: 700px;
float: left;
margin-right: 50px;
margin-left: 220px;
}
nav a{
font-size: 14px;
line-height: 90px;
margin-right: 80px;
text-decoration: none;
color: black;
}
nav a.a{
border-bottom: 2px solid #b4a078;
color: #b4a078;
padding-bottom: 2px;
}
nav a.aa{
margin-right: 600px;
}
nav a:hover{
color: #b4a078;
}
div.seven_images{
width: 1090px;
height: 570px;
background-color: violet;
margin: 0 auto;
display: flex;
justify-content: space-between ;
}
div.seven_image1{
width: 390px;
background-color: teal;
display: flex;
flex-direction: column;
justify-content: space-between;
}
div.seven_image2{
width: 223px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
div.seven_image2>div{
height: 280px;
background-color: yellowgreen;
text-align: center;
}
div.seven_image1 div:first-child{
height: 400px;
background-color: yellow;
}
div.seven_image1 div:last-child{
height: 150px;
background-color: yellow;
text-align: center;
}
div.seven_image1 div:last-child>p:first-child span{
background-color: #e36844;
color: #fff ;
display: inline-block;
height: 20px;
line-height: 20px;
padding: 0 5px;
font-size: 12px;
}
div.seven_image1 div:last-child>p:nth-child(2) span{
line-height: 26px;
font-size: 18px;
display: inline-block;
}
div.seven_image1 div:last-child>p:last-child {
line-height: 13px;
padding: 1px 0 9px;
text-align: center;
}
div.seven_image1 div:last-child>p:last-child span:first-child{
font-size: 18px;
height: 18px;
display: inline-block;
color: #d4282d;
line-height: 10px;
}
div.seven_image1 div:last-child>p:last-child span:last-child{
font-size: 14px;
color: #999;
text-decoration: line-through;
}
div.seven_image2>div{
display: flex;
flex-direction: column;
justify-content: space-between;
}
div.seven_image2>div>div:first-child{
height: 180px;
background-color: turquoise;
}
div.seven_image2>div>div:last-child{
height: 92.3px;
background-color: turquoise;
font-size: 13px;
}
div.seven_image2>div>div:last-child p{
margin: 5px;
}
div.seven_image2>div>div:last-child p:first-child>span{
height: 20px;
line-height: 20px;
color: #fff;
padding: 0 5px;
background-color: #e36844;
font-size: 12px;
display: inline-block;
}
div.seven_image2>div>div:last-child p:nth-child(2)>span{
/* line-height: 20px; */
font-size: 14px;
}
div.seven_image2>div>div:last-child p:last-child>span:first-child{
line-height: 13px;
height: 13px;
display: inline-block;
font-size: 13px;
color: #d4282d;
}
div.seven_image2>div>div:last-child p:last-child>span:last-child{
color: #999;
font-size: 12px;
text-decoration: line-through;
}
效果图
**注:**背景颜色用来布局时区分模块,布局完成,删除背景颜色,或替换背景颜色即可。