HTML响应式布局实例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
li{list-style: none;}
a{cursor: pointer;}
header{
height: 50px;
background: rgba(0,0,0,0.7);
position: fixed;
width: 100%;
}
header .menu{
display: none;
float: right;
margin-right: 20px;
color: white;
font-size: 18px;
line-height: 50px;
}
header .menu .nav-list{
width: 100%;
position: fixed;
top: 50px;
left: 0;
}
header .menu .nav-list a{
display: block;
width: 100%;
height: 50px;
background: rgba(0,0,0,0.6);
text-align: center;
border-bottom: 1px solid white;
}
header .menu{cursor: pointer;}
header .menu:hover .nav-list{
display: block;
}
header img{
float: left;
width: 150px;
margin-left:30px ;
height: 50px;
}
header .nav-list{
display: block;
float: right;
line-height: 50px;
margin-right: 20px;
}
header .nav-list a{
color: white;
float: left;
font-size: 18px;
line-height: 50px;
margin-bottom: 20px;
}
.banner{
border: 1px solid red;
width: 100%;
height: 400px;
margin-bottom: 20px;
}
.banner img{
width: 100%;
height: 400px;
}
.product-list li{
box-sizing: border-box;
width: 20%;
float: left;
padding: 0 10px 10px;
}
.product-list img{
width: 100%;
border-radius: 50px;
box-shadow: 0 0 6px #666;
}
@media screen and (max-width:1024px) {
.product-list li{
width: 25%;
}
}
@media screen and (max-width:768px) {
.product-list li{
width: 33.333%;
}
header .menu{
display: block;
}
header .nav-list{
display: none;
}
}
@media screen and (max-width:640px) {
.product-list li{
width: 50%;
}
}
</style>
</head>
<body>
<header>
<div class="menu">
menu
<nav class="nav-list">
<a>文章1</a>
<a>文章2</a>
<a>文章3</a>
<a>文章4</a>
<a>文章5</a>
<a>文章6</a>
</nav>
</div>
<img src="img/4.jpg" >
<nav class="nav-list">
<a>文章1</a>
<a>文章2</a>
<a>文章3</a>
<a>文章4</a>
<a>文章5</a>
<a>文章6</a>
</nav>
</header>
<div class="banner">
<img src="img/44.jpg" >
</div>
<div id="">
<ul class="product-list">
<li>
<div >
<img src="https://s0.2mdn.net/simgad/4591283466738795132" >
<p>手机</p>
<p>
<span>
2020-12-12
</span>
<span>作者:</span>
</p>
</div>
</li>
<li>
<div >
<img src="https://s0.2mdn.net/simgad/4591283466738795132" >
<p>手机</p>
<p>
<span>
2020-12-12
</span>
<span>作者:</span>
</p>
</div>
</li>
<li>
<div >
<img src="https://s0.2mdn.net/simgad/4591283466738795132" >
<p>手机</p>
<p>
<span>
2020-12-12
</span>
<span>作者:</span>
</p>
</div>
</li>
<li>
<div >
<img src="https://s0.2mdn.net/simgad/4591283466738795132" >
<p>手机</p>
<p>
<span>
2020-12-12
</span>
<span>作者:</span>
</p>
</div>
</li>
<li>
<div >
<img src="https://s0.2mdn.net/simgad/4591283466738795132" >
<p>手机</p>
<p>
<span>
2020-12-12
</span>
<span>作者:</span>
</p>
</div>
</li>
<li>
<div >
<img src="https://s0.2mdn.net/simgad/4591283466738795132" >
<p>手机</p>
<p>
<span>
2020-12-12
</span>
<span>作者:</span>
</p>
</div>
</li>
<li>
<div >
<img src="https://s0.2mdn.net/simgad/4591283466738795132" >
<p>手机</p>
<p>
<span>
2020-12-12
</span>
<span>作者:</span>
</p>
</div>
</li>
</ul>
</div>
</body>
</html>