淘宝首页商品布局
index.css布局内容
* {
padding: 0;
margin: 0;
}
body {
width: 100%;
height: 100%;
background-color: #eee;
}
.container {
width: 1200px;
height: 450px;
background-color: #fff;
margin: 0 auto;
box-sizing: border-box;
padding: 20px;
}
.container .title {
display: flex;
}
.container .title .title_span {
color: #111;
font-weight: bold;
font-size: 24px;
}
.container .title .title_img {
width: 64px;
height: 18px;
margin: 10px 0 0 6px;
}
.container .product_info {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
margin-top: 15px;
}
.container .product_info .item {
width: 378px;
height: 178px;
background-color: #eee;
border-radius: 8px;
box-sizing: border-box;
padding: 10px;
display: flex;
}
.container .product_info .item:hover {
border: 1px solid #ff5000;
}
.container .product_info .item img {
width: 150px;
height: 150px;
border-radius: 8px;
}
.container .product_info .item .product_title {
padding-left: 10px;
display: flex;
flex-direction: column;
place-content: space-between;
}
.container .product_info .item .product_title .product_sub div:first-of-type {
margin-bottom: 10px;
}
.container .product_info .item .product_title .tag_item {
border: 1px solid #f40;
color: #ff5000;
border-color: #fab596;
background: #ffffff;
font-size: 12px;
padding: 3px 5px;
border-radius: 5px;
}
.container .product_info .item .product_title .product_price {
color: #ff5000;
font-size: 22px;
}
.container .product_info .item .product_title .product_price span {
font-size: 14px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<link rel="stylesheet" href="./css/index.css" />
</head>
<body>
<div class="container">
<div class="title">
<span class="title_span">猜你喜欢</span>
<img
class="title_img"
src="https://gw.alicdn.com/imgextra/i2/O1CN016b1mMM1FxJlsXfWhU_!!6000000000553-2-tps-96-30.png"
alt=""
/>
</div>
<div class="product_info">
<div class="item">
<img
src=" https://gw.alicdn.com/bao/uploaded/i4/2201203762970/O1CN01k9xViY1XoJ5JhDhwG_!!0-item_pic.jpg_300x300q90.jpg_.webp"
alt=""
/>
<div class="product_title">
<div class="product_sub">
<div>
坚果零食大礼包每日坚果混合休闲食品坚果组合小包装年货干果散装
</div>
<span class="tag_item">运费险</span>
</div>
<div class="product_price">
<span>¥</span>
9.9
</div>
</div>
</div>
<div class="item">
<img
src=" https://gw.alicdn.com/bao/uploaded/i4/2201203762970/O1CN01k9xViY1XoJ5JhDhwG_!!0-item_pic.jpg_300x300q90.jpg_.webp"
alt=""
/>
<div class="product_title">
<div class="product_sub">
<div>
坚果零食大礼包每日坚果混合休闲食品坚果组合小包装年货干果散装
</div>
<span class="tag_item">运费险</span>
</div>
<div class="product_price">
<span>¥</span>
9.9
</div>
</div>
</div>
<div class="item">
<img
src=" https://gw.alicdn.com/bao/uploaded/i4/2201203762970/O1CN01k9xViY1XoJ5JhDhwG_!!0-item_pic.jpg_300x300q90.jpg_.webp"
alt=""
/>
<div class="product_title">
<div class="product_sub">
<div>
坚果零食大礼包每日坚果混合休闲食品坚果组合小包装年货干果散装
</div>
<span class="tag_item">运费险</span>
</div>
<div class="product_price">
<span>¥</span>
9.9
</div>
</div>
</div>
</div>
</div>
</body>
</html>
效果展示图