12-28作业:Grid布局版 商品交易区
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>公共花卉交易区</title>
<link rel="stylesheet" href="grid_public_second_hand.css">
</head>
<body>
<!--引入大标题-->
<div class="public-headline">
<span>花卉交易</span>
</div>
<!--花卉交易区-->
<div class="public-second-hand">
<!-- 标题一-->
<div class="title-first">
<a href="">抢好货</a>
<span> 0低价, 便捷,安全,快速 </span>
</div>
<!-- 标题二-->
<div class="title-second">
<span>热门分类</span>
<a href="">蓝紫色</a>
<a href="">紫红色</a>
<a href="">白色</a>
<a href="">粉红色</a>
<a href="">红色</a>
<a href="">绿色</a>
</div>
<!-- <div class="goods">-->
<div class="goods-list">
<div class="intro">
<a href=""><img src="../../../static/images/shop/shop1.jpg" alt=""></a>
<a href="">桃红色颜色大丽花花孤立孤芳自赏的美丽花</a>
<div>
<span>¥ 389</span>
<span>红色花</span>
</div>
</div>
<div class="intro">
<a href=""><img src="../../../static/images/shop/shop2.jpg" alt=""></a>
<a href="">桃红色颜色大丽花花孤立孤芳自赏的美丽花</a>
<div>
<span>¥ 389</span>
<span>红色花</span>
</div>
</div>
<div class="intro">
<a href=""><img src="../../../static/images/shop/shop3.jpg" alt=""></a>
<a href="">桃红色颜色大丽花花孤立孤芳自赏的美丽花</a>
<div>
<span>¥ 389</span>
<span>红色花</span>
</div>
</div>
<div class="intro">
<a href=""><img src="../../../static/images/shop/shop4.jpg" alt=""></a>
<a href="">桃红色颜色大丽花花孤立孤芳自赏的美丽花</a>
<div>
<span>¥ 389</span>
<span>红色花</span>
</div>
</div>
<div class="intro">
<a href=""><img src="../../../static/images/shop/shop5.jpg" alt=""></a>
<a href="">桃红色颜色大丽花花孤立孤芳自赏的美丽花</a>
<div>
<span>¥ 389</span>
<span>红色花</span>
</div>
</div>
<div class="intro">
<a href=""><img src="../../../static/images/shop/shop6.jpg" alt=""></a>
<a href="">桃红色颜色大丽花花孤立孤芳自赏的美丽花</a>
<div>
<span>¥ 389</span>
<span>红色花</span>
</div>
</div>
<div class="intro">
<a href=""><img src="../../../static/images/shop/shop7.jpg" alt=""></a>
<a href="">桃红色颜色大丽花花孤立孤芳自赏的美丽花</a>
<div>
<span>¥ 389</span>
<span>红色花</span>
</div>
</div>
<div class="intro">
<a href=""><img src="../../../static/images/shop/shop8.jpg" alt=""></a>
<a href="">桃红色颜色大丽花花孤立孤芳自赏的美丽花</a>
<div>
<span>¥ 389</span>
<span>红色花</span>
</div>
</div>
</div>
<div class="quick-entry">
<a href=""><img src="../../../static/images/ad/1.png" alt=""></a>
<a href=""><img src="../../../static/images/ad/2.png" alt=""></a>
<a href=""><img src="../../../static/images/ad/3.png" alt=""></a>
<a href=""><img src="../../../static/images/ad/4.png" alt=""></a>
<a href=""><img src="../../../static/images/ad/image.png" alt=""></a>
<a href=""><img src="../../../static/images/ad/ad2.jpg" alt=""></a>
</div>
</div>
<!--</div>-->
</body>
</html>
@import "../public_reset.css";
@import "../public_headline/public_headline.css";
.public-second-hand {
width: 1200px;
/*padding: 10px;*/
box-sizing: border-box;
margin: auto;
background-color: #ffffff;
display: grid;
grid-template-columns: 800px 400px;
grid-template-rows: 50px 50px 450px ;
/*grid-gap: 10px;*/
}
.public-second-hand:hover {
box-shadow: 0 0 8px #888888;
}
.public-second-hand > .title-first {
padding: 10px;
grid-row: 1 / 2;
grid-column: 1 / 3;
border-bottom: 1px solid #cccccc;
box-sizing: border-box;
}
.public-second-hand > .title-first > a{
font-size: 23px;
margin-right: 20px;
}
.public-second-hand > .title-first > span {
color: red;
}
.public-second-hand > .title-second {
padding: 10px;
box-sizing: border-box;
grid-row: 2 / 3;
grid-column: 1 / 3;
}
.public-second-hand > .title-second > span {
font-size: 23px;
color: red;
}
.public-second-hand > .title-second > span ~ a {
margin-left: 20px;
}
.public-second-hand > .goods-list {
grid-row: 3 / 4;
grid-column: 1 / 2;
display: grid;
grid-template-rows: repeat(2, 210px);
grid-template-columns: repeat(4, 200px);
}
.public-second-hand > .goods-list > .intro {
padding: 10px;
box-sizing: border-box;
display: grid;
grid-template-rows: 130px 50px 20px;
grid-template-columns: 200px;
}
.public-second-hand > .goods-list > .intro > a {
padding: 5px;
box-sizing: border-box;
}
.public-second-hand > .goods-list > .intro > a img {
width: 180px;
height: 120px;
border-radius: 5px;
}
.public-second-hand > .goods-list > .intro > div {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
padding: 0 10px;
}
.public-second-hand > .goods-list > .intro > div > span:first-of-type{
color: red;
}
.public-second-hand > .goods-list > .intro > div > span:last-of-type{
color: white;
padding: 0 5px;
background-color: #55ce9f;
margin-left: auto;
}
.public-second-hand > .quick-entry {
display: grid;
grid-template-rows: 150px 150px 55px 55px;
grid-template-columns: repeat(2, 200px);
}
.public-second-hand > .quick-entry > a {
padding: 15px;
box-sizing: border-box;
}
.public-second-hand > .quick-entry > a img {
width: 170px;
height: 130px;
}
.public-second-hand > .quick-entry a:nth-of-type(5){
grid-row: 3 / 4;
grid-column: 1 / 3;
padding: 0 15px;
}
.public-second-hand > .quick-entry a:nth-of-type(5) > img{
width: 370px;
height: 55px;
}
.public-second-hand > .quick-entry a:nth-of-type(6){
grid-row: 4 / 5;
grid-column: 1 / 3;
padding: 0 15px;
}
.public-second-hand > .quick-entry a:nth-of-type(6) > img{
width: 370px;
height: 55px;
}
完成图
总结
- Grid 布局个人感觉适合整体大布局,小的方面还没有flex 简单;
- 可能是第一次接触,就是觉得有点麻烦,比如flex 设定大方向,里面的细节处理都不需要去仔细研究,感觉没有flex智能,还需要多联系;
附:手写Gird 属性文档