效果图
HTML
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PC端淘宝</title>
<link rel="stylesheet" href="static/css/taobao-pc.css">
</head>
<body>
<!-- 顶部导航栏 -->
<div class="topbar">
<div class="container">
<ul class="topbar-ul">
<li class="dropdown topbar-item-region">
<div class="dropdown-selected">
<span>中国大陆</span>
<span class="iconfont"></span>
</div>
<ul class="dropdown-list">
<li>全球</li>
<li>中国大陆</li>
<li>中国香港</li>
<li>中国台湾</li>
<li>中国澳门</li>
<li>韩国</li>
<li>马来西亚</li>
<li>澳大利亚</li>
<li>新加波</li>
<li>新西兰</li>
</ul>
</li>
<li><a style="color: #f40;">亲,请先登录</a><a>免费注册</a></li>
<li><a>手机淘宝</a></li>
<li><a>网页无障碍</a></li>
</ul>
<ul class="topbar-ul">
<li><a>我的淘宝</a></li>
<li><a><i class="iconfont" style="color: #f40;"></i> 购物车</a></li>
<li><a>收藏夹</a></li>
</ul>
</div>
</div>
<!-- 快速入口 -->
<div class="entry">
<div class="container">
<div class="item place-text" place-text="图标"></div>
<div class="item place-text" place-text="类目1"></div>
<div class="item place-text" place-text="类目2"></div>
<div class="item place-text" place-text="类目3"></div>
<div class="item place-text" place-text="类目4"></div>
<div class="item place-text" place-text="类目5"></div>
</div>
</div>
<!-- 主体部分 -->
<div class="container main">
<!-- 头部 -->
<div class="header">
<div class="logo place-text" place-text="LOGO"></div>
<div class="search place-text" place-text="搜索框"></div>
<div class="qrcode place-text" place-text="二维码"></div>
</div>
<!-- 导航/轮播/用户信息 -->
<div class="screen">
<div class="screen-menu place-text" place-text="分类导航"></div>
<div class="screen-main">
<div class="screen-nav place-text" place-text="快捷导航"></div>
<div class="screen-slide place-text" place-text="轮播图"></div>
<div class="screen-user place-text" place-text="用户信息"></div>
</div>
</div>
<!-- 商品列表 -->
<div class="list">
<div class="title">
<h2>猜你喜欢</h2>
<label>个性推荐</label>
</div>
<div class="list-row">
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title">商品描述商品描述商品描述商品描述</div>
<div class="info-tag"><label class="tag-yfx">运送费险</label></div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title"><label class="tag-hot">HOT</label>商品描述商品描述商品描述商品描述</div>
<div class="info-tag"><label class="tag-yfx">运送费险</label></div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title"><label class="tag-hot">天猫双11</label>商品描述商品描述商品描述商品描述</div>
<div class="info-tag"><label class="tag-yfx">运送费险</label></div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title"><label class="tag-hot">HOT</label>商品描述商品描述商品描述商品描述</div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title">商品描述商品描述商品描述商品描述</div>
<div class="info-tag"><label class="tag-yfx">运送费险</label></div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title"><label class="tag-hot">天猫双11</label>商品描述商品描述商品描述商品描述</div>
<div class="info-tag"><label class="tag-yfx">运送费险</label></div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title"><label class="tag-hot">HOT</label>商品描述商品描述商品描述商品描述</div>
<div class="info-tag"><label class="tag-yfx">运送费险</label></div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title"><label class="tag-hot">天猫双11</label>商品描述商品描述商品描述商品描述</div>
<div class="info-tag"><label class="tag-yfx">运送费险</label></div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
<a class="item">
<div class="pic place-text" place-text="封面图"></div>
<div class="info">
<div class="desc">
<div class="info-title"><label class="tag-hot">HOT</label>商品描述商品描述商品描述商品描述</div>
</div>
<div class="price"><em>¥</em> 59.9</div>
</div>
</a>
</div>
</div>
</div>
<div class="footer">
<div class="container">
<p style="text-align: center;">底部版权信息</p>
</div>
</div>
</body>
</html>
CSS
/* 重置基础样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-size: 14px;
color: #333;
background-color: #f6f6f6;
}
a {
color: #333;
cursor: pointer;
text-decoration: none;
}
a:hover {
color: #FF5000;
transition: all .3s;
}
li {
list-style: none;
}
img {
border: none;
width: 100%;
}
i,em,cite {
font-style: normal;
}
/* 占位文本 */
.place-text {
position: relative;
}
.place-text:before{
position: absolute;
content: attr(place-text);
top: 50%;
left:50%;
transform: translate(-50%, -50%);
color: #bbb;
}
/* 全局容器宽度适应 */
.container {
margin: 0 auto;
padding: 0 20px;
}
@media (min-width: 768px) {
.container {
width: 750px;
}
}
@media (min-width: 992px) {
.container {
width: 970px;
}
}
@media (min-width: 1200px) {
.container {
width: 1170px;
}
}
/* 图标字体 */
@font-face {
font-family: 'iconfont'; /* Project id 3738571 */
src: url('https://at.alicdn.com/t/c/font_3738571_w9b16dc3ye.woff2?t=1667204474667') format('woff2'),
url('https://at.alicdn.com/t/c/font_3738571_w9b16dc3ye.woff?t=1667204474667') format('woff'),
url('https://at.alicdn.com/t/c/font_3738571_w9b16dc3ye.ttf?t=1667204474667') format('truetype');
}
.iconfont {
font-family: 'iconfont' !important;
font-size: 16px;
font-style: normal;
}
/* 顶部栏 */
.topbar {
height: 35px;
background-color: #f5f5f5;
border-bottom: 1px solid #eee;
}
.topbar>.container {
display: flex;
flex-flow: row nowrap;
place-content: space-between;
}
.topbar .topbar-ul>li{
display: inline-block;
line-height: 35px;
font-size: 12px;
}
.topbar .topbar-ul>li+li {
margin-left: 10px;
}
.topbar .topbar-ul>li .iconfont {
font-size: 12px;
}
.topbar .topbar-ul>li>a+a {
margin-left: 8px;
}
/* 下拉菜单 */
.dropdown {
position: relative;
z-index: 9;
}
/* 下拉默认选中展示的文字 */
.dropdown-selected {
position: relative;
padding: 0 20px 0 6px;
cursor: pointer;
}
/* 下拉右侧小箭头 */
.dropdown-selected .iconfont {
position: absolute;
right: 0;
font-size: 12px;
}
/* 下拉菜单列表 */
ul.dropdown-list {
display: none;
position: absolute;
top: 35px;
left: 0;
background-color: #fff;
padding: 8px 0;
height: 240px;
overflow-x: hidden;
}
ul.dropdown-list>li {
cursor: pointer;
width: 150px;
line-height: 28px;
padding: 0 6px;
}
ul.dropdown-list>li:hover {
background-color: #f4f4f4;
}
/* 当鼠标碰到高亮背景色 */
.dropdown:hover .dropdown-selected {
background-color: #fff;
}
.dropdown:hover ul.dropdown-list{
display: block;
}
/*快速入口*/
.entry {
background-color: #ff72b5;
padding: 15px 0;
height: 100px;
}
.entry>.container {
display: grid;
grid-template-columns: 100px repeat(5, 1fr);
grid-auto-rows:70px;
gap: 10px;
}
.entry .item {
border-radius:10px;
background-color: #fff;
}
/* 主体 */
.main {
background-color: #fff;
padding:30px;
margin-bottom: 20px;
}
/*头部区*/
.header {
/*粘性定位*/
position: static;
top: 0;
display: grid;
grid-template-columns: 200px 12fr 90px;
height: 90px;
gap: 30px;
margin-bottom: 20px;
}
.header>* {
background-color: #eee;
text-align: center;
line-height: 90px;
}
/* 导航/轮播/用户信息 */
.screen {
display: grid;
grid-template-columns: 270px 1fr;
gap: 15px;
height: 360px;
margin-bottom: 20px;
}
.screen-menu,
.screen-main > .screen-nav,
.screen-main > .screen-slide,
.screen-main > .screen-user{
background-color: #eee;
border-radius: 10px;
}
.screen-main {
display: grid;
grid-template-columns: 1.5fr 1fr;
grid-template-rows: 40px 1fr;
gap: 10px;
}
.screen-nav {
grid-column: span 2;
}
/* 列表标题栏 */
.title {
display: flex;
place-items: center;
margin-bottom: 20px;
}
.title>h2 {
color: #000;
font-weight: bold;
font-size: 24px;
}
.title>label {
background: linear-gradient(to left, orangered, orange);
color: #fff;
border-radius: 5px;
padding: 0 5px;
margin-left: 6px;
}
/* 商品列表 */
.list-row {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-auto-rows: 175px;
gap: 15px;
}
.list-row > .item {
display: grid;
grid-template-columns: 150px 1fr;
gap: 10px;
background-color: #f7f9fa;
border: 1px solid #f7f9fa;
border-radius: 10px;
padding: 10px;
}
.list-row > .item:hover {
background-color: #fff;
border-color: #ff915e;
box-shadow: 0 8px 12px 0 rgb(255 80 0 / 6%);
}
.list-row > .item > .pic {
background-color: rgb(0 0 0 / 6%);
border-radius: 5px;
}
.list-row > .item > .pic > img {
width: 100%;
border-radius: 5px;
}
.list-row > .item > .info {
display: grid;
grid-template-rows: 1fr 25px;
place-content: space-between;
line-height: 1.5;
padding: 10px 0;
}
.list-row > .item .info-title {
color: #333;
font-size: 16px;
overflow: hidden;
max-height: 46px;
}
.list-row >.item .price {
font-size: 22px;
color: #ff5000;
}
.list-row > .item .tag-hot {
background: linear-gradient(to left, orangered, orange);
color: #fff;
border-radius: 3px;
padding: 0 5px;
margin-right: 6px;
font-size: 12px;
}
.list-row > .item .tag-yfx {
color: #FF5000;
border: 1px solid #FAB596;
background: #fff;
border-radius: 3px;
padding: 0 5px;
margin-right: 6px;
font-size: 12px;
}
.footer {
padding: 20px 0;
background-color: #fff;
}
@media (max-width: 1200px) {
.list-row > .item {
grid-template-columns: 120px 1fr;
}
}
@media (max-width: 992px) {
.entry>.container {
grid-template-columns: 100px repeat(4, 1fr);
}
.entry .item:last-of-type {
display: none;
}
.screen {
grid-template-columns: 1fr;
}
.screen-menu {
display: none;
}
.list-row {
grid-template-columns: repeat(2, 1fr);
}
}