正在回答
4回答
因为小圆点你设置的是display:inline-block;这种显示状态有默认的行间距,所以将包含着小圆点的盒子撑大了
OlafChou
2017-08-25 08:01:50
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Banner轮播</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <div class="main"> <!--图片轮播 --> <div class="banner"> <a href=""> <div class="banner-slide slide1 slide-active"></div> </a> <a href=""> <div class="banner-slide slide2"></div> </a> <a href=""> <div class="banner-slide slide3"></div> </a> </div> <!-- 上一张,下一张按钮 --> <a href="javascript:void(0)" class="button prev"></a> <a href="javascript:void(0)" class="button next"> </a> <!-- 圆点导航 --> <div class="dots"> <span class="active"></span> <span></span> <span></span> </div> </div> <script type="text/javascript" ></script> </body> </html>
*{
margin: 0;
padding:0;
}
li{
list-style: none;
}
body{
font-family: "微软雅黑";
color: #14191e;
}
.main{
width: 1200px;
height: 460px;
margin: 30px auto;
overflow: hidden;
position: relative;
}
.banner{
width:1200px;
height:460px;
position: relative;
}
.banner-slide{
width: 1200px;
height: 460px;
background-repeat: no-repeat;
position: absolute;
display: none;
}
.slide-active{
display: block;
}
.slide1{
background-image: url(../img/bg1.jpg);
}
.slide2{
background-image: url(../img/bg2.jpg);
}
.slide3{
background-image: url(../img/bg3.jpg);
}
.button{
position: absolute;
width: 40px;
height: 80px;
left: 244px;
top:50%;
margin-top: -40px;
background:url(../img/arrow.png) no-repeat center center;
}
.button:hover{
/* 这里不能用background:#333; */
background-color: #333;
opacity: 0.2;
/*透明度兼容性*/
filter: alpha(opacity=20);
}
.prev{
transform:rotate(180deg);
}
.next{
/*left的优先级高于right*/
left: auto;
right: 0;
}
.dots{
position:absolute;
right:20px;
bottom:24px;
text-align:right;
}
.dots span{
display:inline-block;
width:12px;
height:12px;
line-height:12px;
border-radius:50%;
background: rgba(7,17,27,0.4);
box-shadow: 0 0 0 2px rgba(255,255,255,0.8) inset;
margin-left:8px;
cursor: pointer;
}
.dots span.active{
box-shadow: 0 0 0 2px rgba(7,17,27,0.4) inset;
background: #fff;
}
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程


恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星