二级菜单
思路:
- 一个大盒子,定宽定高,内部一个盒子,宽高是图片横向排列的总宽度。
- 大盒子overflow:hidden;
补充:转变为行盒可以自动适应行高。
代码
html
<div class="banner">
<div class="imgs">
<a href=""><img src="./img/1.jpg" alt=""></a>
<a href=""><img src="./img/2.jpg" alt=""></a>
<a href=""><img src="./img/3.jpg" alt=""></a>
</div>
<div class="left"><</div>
<div class="right">></div>
<div class="modal">
<div class="title">
<h2>黄河三峡风景如画</h2>
</div>
<div class="dots">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
</div>
css
.banner {
width: 520px;
height: 304px;
margin: 1em auto;
overflow: hidden;
position: relative;
}
.banner .imgs {
width: 1560px;
height: 304px;
}
.banner .imgs img {
width: 520px;
height: 304px;
}
.banner .imgs a {
float: left;
}
.banner .left,
.banner .right {
position: absolute;
width: 50px;
height: 50px;
top: 0;
bottom: 0;
margin: auto;
font-size: 3em;
text-align: center;
font-family: Arial;
color: #fff;
border-radius: 50%;
line-height: 50px;
cursor: pointer;
}
.banner .left:hover,
.banner .right:hover {
background: #fff;
color: #f40;
}
.banner .left {
left: 20px;
}
.banner .right {
right: 20px;
}
.banner .modal{
width: 100%;
height: 40px;
background: rgba(0,0,0,.3);
position: absolute;
left: 0;
bottom: 0;
color: #fff;
line-height: 40px;
padding: 0 20px;
box-sizing: border-box;
}
.banner .modal .title{
float: left;
font-weight: bold;
}
.banner .modal .dots{
float: right;
}
.banner .modal .dots li{
width: 8px;
height: 8px;
background: #ccc;
display: inline-block;
margin: 0 2px;
border-radius: 50%;
cursor: pointer;
}
.banner .modal .dots li:hover{
background: #369;
}