话不多说,先上图:
注意:左侧的滑动栏,是因为父盒子的高度装不下子盒子所有高度了,所以给父盒子设置了overflow:auto,就有了侧边下滑栏了!
代码:
workpage2.html
<!DOCTYPE html>
<html lang="en">
<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">
<link rel="stylesheet" href="styles/base.css">
<link rel="stylesheet" href="styles/workpage2.css">
<link rel="shortcut icon" href="jdweek01.ico">
<title>华为</title>
</head>
<body>
<div class="phonepage">
<!-- 头部区域header 开始 -->
<div class="header">
<div>
<h3>排行榜</h3>
</div>
<div class="label">
<ul>
<li>
<a style="margin-left: 20px;" href="">综合榜</a>
</li>
<li>
<a href="">热卖榜</a>
</li>
<li>
<a href="">热评榜</a>
</li>
<li>
<a href="">热搜榜</a>
</li>
</ul>
</div>
<div class="nav clearfix">
<ul>
<li style="margin-left: 30px;"><a style=" background-color: #d23e34 ;" href="">华为</a></li>
<li><a href="">全部</a></li>
<li><a href="">iphone</a></li>
<li><a href="">华为</a></li>
<li><a href="">海淘</a></li>
<li><a href="">智能家居</a></li>
<li><a href="">电动汽车</a></li>
</ul>
<span> <a href="">3H</a> </span>
</div>
</div>
<!-- 头部区域header 结束 -->
<!-- 内容区域 开始 -->
<div class="content clearfix">
<ul>
<!-- 第一个物品 -->
<li>
<div class="imgs">
<a href=""><img src="images/freebudspro.jpg" alt=""></a>
</div>
<div class="right">
<h4>华为Freebudspro真无线主动降噪耳机 长续航 好音质 无线充电版 售后无忧</h4>
<div class="label_1">精选</div>
<p>1099元(包邮、需用券)</p>
<div class="leftfoot">
<i>京东精选</i>
</div>
<div class="rightfoot">
<button class="bt1">166</button>
<button class="bt2">四川 成都</button>
</div>
</div>
<div class="rank">
<p>TOP1</p>
</div>
<div class="bottom">
<p>
<i>入选理由:</i>真无线动态降噪,透传人声,续航可达32小时,可以适配ios系统
</p>
</div>
<!-- 第二个物品 -->
</li>
<li>
<div class="imgs">
<a href=""><img src="images/chongdianqi.jpg" alt=""></a>
</div>
<div class="right">
<h4>新品发售:Nubia 努比亚 GaN氮化镓充电器 120W 单C口 快充套装</h4>
<div class="label_1">精选</div>
<p>259元(包邮、需用券)</p>
<div class="leftfoot">
<i>京东精选</i>
</div>
<div class="rightfoot">
<button class="bt1">135</button>
<button class="bt2">湖北武汉</button>
</div>
</div>
<div class="rank">
<p>TOP2</p>
</div>
<div class="bottom">
<p>
<i>入选理由:</i>65W输出,标配6A快充数据线,兼容多种协议
</p>
</div>
</li>
<li>
<div class="imgs">
<a href=""><img src="images/mate40pro.jpg" alt=""></a>
</div>
<div class="right">
<h4>华为mate40pro 徕卡五摄 超感知影像 麒麟9000加持 生而强悍</h4>
<div class="label_1">精选</div>
<p>6499元(爆款、稀缺)</p>
<div class="leftfoot">
<i>京东精选</i>
</div>
<div class="rightfoot">
<button class="bt1">205</button>
<button class="bt2">重庆</button>
</div>
</div>
<div class="rank">
<p>TOP3</p>
</div>
<div class="bottom">
<p>
<i>入选理由:</i>瀑布屏搭配90HZ高刷,让你爱不释手,高清拍摄,照亮你的美
</p>
</div>
</li>
<li>
<div class="imgs">
<a href=""><img src="images/ipadpro.jpg" alt=""></a>
</div>
<div class="right">
<h4>Apple 苹果 ipadpro 平板电脑 A14仿生芯片</h4>
<div class="label_1">精选</div>
<p>5888元包邮</p>
<div class="leftfoot">
<i>京东精选</i>
</div>
<div class="rightfoot">
<button class="bt1">166</button>
<button class="bt2">上海</button>
</div>
</div>
<div class="rank">
<p>TOP4</p>
</div>
<div class="bottom">
<p>
<i>入选理由:</i>A14芯片,升级全面屏,超清显示
</p>
</div>
</li>
<li>
<div class="imgs">
<a href=""><img src="images/sk2.jpg" alt=""></a>
</div>
<div class="right">
<h4>SK—II 大红瓶面霜肌源修护精华霜淡宝石淡化滋润80g/瓶</h4>
<div class="label_1">精选</div>
<p>678.3元</p>
<div class="leftfoot">
<i>京东精选</i>
</div>
<div class="rightfoot">
<button class="bt1">265</button>
<button class="bt2">陕西西安</button>
</div>
</div>
<div class="rank">
<p>TOP5</p>
</div>
<div class="bottom">
<p>
<i>入选理由:</i>经典爆款神仙水,大受好评
</p>
</div>
</li>
<li>
<div class="imgs">
<a href=""><img src="images/sku-6.jpg" alt=""></a>
</div>
<div class="right">
<h4>EPIC商城喜加一! 动作中文游戏《井中生物》限时免费!</h4>
<div class="label_1">精选</div>
<p>0元</p>
<div class="leftfoot">
<i>京东精选</i>
</div>
<div class="rightfoot">
<button class="bt1">322</button>
<button class="bt2">贵州遵义</button>
</div>
</div>
<div class="rank">
<p>TOP6</p>
</div>
<div class="bottom">
<p>
<i>入选理由:</i>《井中生物》是一款俯视视角、弹珠式、砍杀类迷宫探索游戏
</p>
</div>
</li>
</ul>
</div>
<!-- 内容区域 结束-->
</div>
</body>
</html>
base.css
@font-face {
font-family: 'icomoontext';
src: url('../fonts/icomoontext.eot?iuore7');
src: url('../fonts/icomoontext.eot?iuore7#iefix') format('embedded-opentype'), url('../fonts/icomoontext.ttf?iuore7') format('truetype'), url('../fonts/icomoontext.woff?iuore7') format('woff'), url('../fonts/icomoontext.svg?iuore7#icomoontext') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
/* 把我们所有标签的内外边距清零 */
* {
margin: 0;
padding: 0;
/* css3盒子模型 */
box-sizing: border-box;
}
/* em 和 i 斜体的文字不倾斜 */
em,
i {
font-style: normal
}
/* 去掉li 的小圆点 */
li {
list-style: none
}
img {
/* border 0 照顾低版本浏览器 如果 图片外面包含了链接会有边框的问题 */
border: 0;
/* 取消图片底侧有空白缝隙的问题 */
vertical-align: middle
}
button {
/* 当我们鼠标经过button 按钮的时候,鼠标变成小手 */
cursor: pointer
}
a {
text-decoration: none
}
button,
input {
/* "\5B8B\4F53" 就是宋体的意思 这样浏览器兼容性比较好 */
font-family: Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif;
/* 默认有灰色边框我们需要手动去掉 */
border: 0;
outline: none;
}
body {
/* CSS3 抗锯齿形 让文字显示的更加清晰 */
-webkit-font-smoothing: antialiased;
background-color: #fff;
font: 12px/1.5 Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif;
color: #666
}
.hide,
.none {
display: none
}
/* 清除浮动 */
.clearfix:after {
visibility: hidden;
clear: both;
display: block;
content: ".";
height: 0
}
.clearfix {
*zoom: 1
}
workpage2.css
/* 手机主页 */
.phonepage {
width: 1024px;
/* height: 839px; */
/* background-color: #eeeeee; */
background-color: #eeeeee;
margin: 100px auto;
overflow: hidden;
position: relative;
}
.phonepage h3 {
color: #f8ffff;
padding: 20px 0;
}
a {
color: black;
}
/* 头部区域 */
.header {
height: 120px;
background-color: #d43d34;
text-align: center;
}
/* 标签区域 */
.label {
width: 984px;
height: 40px;
margin: 0 auto;
}
.label ul li {
float: left;
}
.label ul li a {
display: inline-block;
padding: 0 100px;
height: 40px;
line-height: 32px;
background-color: #bd372e;
}
.label li a:visited {
color: #f8ffff
}
.label li a:active {
background-color: #ac312a;
}
.label li:first-child a {
border-radius: 10px 0 0 10px;
}
.label li:last-child a {
border-radius: 0 10px 10px 0;
}
/*白色标签 */
.nav {
width: 1024px;
height: 54px;
background-color: #ffffff;
border-radius: 10px 10px 0 0;
position: absolute;
top: 110px;
}
.nav ul li {
float: left;
}
.nav ul li a {
display: block;
margin: 15px 15px;
padding: 0 10px;
height: 30px;
line-height: 30px;
background-color: #f7f7f7;
}
.nav ul li a:active {
color: #ffffff;
background-color: #d23e34;
}
.nav span a {
position: absolute;
top: 19px;
right: 30px;
}
.nav span a::after {
content: '\e91e';
font-family: 'icomoontext';
}
/* 下面内容部分 */
.content {
height: 800px;
overflow-y: auto;
overflow-x: hidden;
position: relative;
}
.content ul li:first-child {
margin-top: 55px;
}
.right .label_1 {
margin-top: 20px;
font-size: 8px;
color: #979797;
}
.content ul li {
height: 203px;
width: 971px;
background-color: #ffffff;
margin: 20px auto;
transition: box-shadow 2s;
position: relative;
}
.content ul li:hover {
box-shadow: 2px 2px 10px 5px rgba(0, 0, 0, .2);
}
.imgs {
height: 150px;
width: 150px;
background-color: black;
position: absolute;
top: 0;
left: 0px;
}
.imgs img {
width: 100%;
}
/* 内容右边 */
.content .right {
width: 500px;
height: 150px;
padding: 10px 0;
position: absolute;
top: 0;
left: 160px;
}
.right h4 {
color: black;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.content .leftfoot {
margin-top: 10px;
}
.right p {
color: #d94038;
margin-top: 50px;
}
/* 内容下面的左边 */
.leftfoot {
position: absolute;
top: 120px;
left: 0px;
color: #979797;
font-size: 8px;
}
.content .bt1 {
display: inline-block;
color: #979797;
font-size: 8px;
background-color: transparent;
position: absolute;
top: 130px;
right: -300px;
}
.content .bt2 {
background-color: transparent;
color: #979797;
font-size: 8px;
display: inline-block;
position: absolute;
top: 130px;
right: -260px;
}
.content .bt1::before {
content: '\e93a';
font-family: 'icomoontext';
font-size: 8px;
}
.content .bt2::before {
content: '\e922';
font-family: 'icomoontext';
font-size: 8px;
}
.content .bottom {
height: 48px;
width: 971px;
padding: 5px;
position: absolute;
top: 152px;
left: 0px;
}
.bottom i {
color: black;
}
/* 排名 */
.content .rank {
text-align: center;
width: 50px;
height: 20px;
color: white;
line-height: 20px;
background-color: #d54137;
border-radius: 5px 0 5px 0;
position: absolute;
top: 0;
left: 0px;
}