二倍图
如果放入的img图片的宽和高大于要放入盒子的宽和高,通常使用二倍图,background- size:x y 进行缩放显示,使img图片可以完全的展示在div盒子中
京东案例
在这里插入代码片
```<!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">
<title>京东</title>
<link rel="stylesheet" href="../JD_he/css/JD.css">
<link rel="stylesheet" href="./base.css">
</head>
<body>
<!-- 这是导航样式 -->
<div class="top">
<div class="daohang">
<div class="left"></div>
<div class="center">
<div class="t1"></div>
<div class="t2"></div>
<input type="text" placeholder="搜索">
</div>
<div class="right">登录</div>
</div>
<img src="./images/banner.dpg" width="100%">
</div>
<!--这是中间样式 -->
<div class="zhong">
<div class="left"><img src="./images/pic11.dpg" width="100%"></div>
<div class="center"><img src="./images/pic22.dpg" width="100%"></div>
<div class="right"><img src="./images/pic33.dpg" width="100%"></div>
</div>
<!-- 这是底部样式 -->
<div class="di">
<div class="top">
<ul>
<li>
<div class="tu">
<img src="./images/nav1.webp" width="100%" height="100%">
</div>
京东超市</li>
<li>
<div class="tu">
<img src="./images/nav2.webp" width="100%" height="100%">
</div>
京东超市</li>
<li>
<div class="tu">
<img src="./images/nav1.webp" width="100%" height="100%">
</div>
京东超市</li>
<li>
<div class="tu">
<img src="./images/nav1.webp" width="100%" height="100%">
</div>
京东超市</li>
<li><div class="tu">
<img src="./images/nav1.webp" width="100%" height="100%">
</div>
京东超市</li>
</ul>
</div>
<div class="bottom">
<ul>
<li>
<div class="tu">
<img src="./images/nav3.webp" width="100%" height="100%">
</div>
京东超市</li>
<li>
<div class="tu">
<img src="./images/nav2.webp" width="100%" height="100%">
</div>
京东超市</li>
<li>
<div class="tu">
<img src="./images/nav1.webp" width="100%" height="100%">
</div>
京东超市</li>
<li>
<div class="tu">
<img src="./images/nav1.webp" width="100%" height="100%">
</div>
京东超市</li>
<li><div class="tu">
<img src="./images/nav1.webp" width="100%" height="100%">
</div>
京东超市</li>
</ul>
</div>
</div>
<!-- 这是最下面的样式 -->
<div class="cn">
<div class="cn1">
<img src="./images/new1.dpg" width="100%" height="100%">
</div>
<div class="cn2">
<img src="./images/new2.dpg" width="100%" height="100%">
</div>
<div class="cn3">
<img src="./images/new3.dpg" width="100%" height="100%">
</div>
</div>
</body>
</html>
## ***CSS样式***
```css
.body{
max-width: 1000px;
/* 最大显示宽度 */
min-width: 400px;
/* 最小显示宽度 */
width: 100%;
}
/* 导航CSS */
.daohang{
width: 814px;
height: 40px;
position: relative;
/* background: pink; */
background: pink;
}
.daohang .left{
width: 30px;
height: 25px;
background: url(../images/../images/fenlei.png) ;
background-size: 30px 25px;
/* 二倍图缩放 */
position: absolute;
left: 10px;
top: 4%;
}
.daohang .right{
width: 28px;
height: 21px;
background: red;
font-size: 14px;
color: white;
position: absolute;
right: 5px;
top: 16%;
}
.daohang .center{
position: relative;
height: 30px;
margin: 0 130px;
box-sizing: border-box;
}
.daohang .center .t1{
width: 20px;
height: 15px;
background: url(../images/jd.png);
background-size: 20px 15px;
background-repeat: no-repeat;
/* 不重叠 */
border-right: 1px solid red;
padding-right: 10px;
position: relative;
z-index: 20;
right: 62px;
top: 8px;
}
.daohang .center .t2{
width: 16px;
height: 18px;
background: url(../images/fdk.png);
background-size: 16px 18px;
background-repeat: no-repeat;
position: relative;
left: -22px;
z-index: 20;
bottom: 8px;
}
.daohang .center input{
width: 722px;
height: 30px;
box-sizing: border-box;
border-radius: 15px;
position: relative;
left: -77px;
bottom: 31px;
padding-left: 80px;
outline: none;
}
.top{
width: 814px;
height: 438px;
}
/* 中间CSS */
.zhong{
width: 814px;
height: 217px;
}
.zhong .left{
width: 271px;
float: left;
}
.zhong .center{
width: 271px;
float: left;
}
.zhong .right{
width: 271px;
float: right;
}
/* 底部CSS */
.di{
width: 814px;
height: 168px;
}
.di .top{
width: 814px;
height: 84px;
}
.di .top .tu{
width: 40px;
height: 40px;
position: relative;
left: 12px;
}
.di .top ul li{
width: 20%;
float: left;
list-style: none;
}
.di .bottom{
width: 814px;
height: 84px;
}
.di .bottom .tu{
width: 40px;
height: 40px;
position: relative;
left: 12px;
}
.di .bottom ul li{
width: 20%;
float: left;
list-style: none;
}
/* 这是最下面的样式 */
.cn{
width: 814px;
height: 203px;
background: red;
}
.cn .cn1{
width: 49%;
height: 203px;
float: left;
}
.cn .cn2{
width: 25%;
height: 203px;
float: left;
}
.cn .cn3{
width: 25%;
height: 203px;
float: right;
}
*