轮播图
代码实现
:
<div class="tb-promo">
<img src="tb1.jpg" alt="">
<!-- 左侧按钮 -->
<a href="#" class="prev"> < </a>
<!-- 右侧按钮 -->
<a href="#" class="next"> > </a>
<!-- 小圆点 -->
<ul class="promo-nav">
<li class="first"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<style>
* {
padding: 0;
margin: 0;
}
li {
list-style: none;
}
.tb-promo {
/* 子绝父相 */
position: relative;
width: 520px;
height: 280px;
background-color: aqua;
margin: 100px auto;
}
.tb-promo img {
width: 520px;
height: 280px;
}
.prev {
position: absolute;
left: 0;
top: 50%;
margin-top: -18px;
text-align: center;
text-decoration: none;
color: #fff;
line-height: 36px;
width: 25px;
height: 36px;
background-color: rgba(0,0,0,.3);
border-top-right-radius: 18px;
border-bottom-right-radius: 18px;
}
.next {
position: absolute;
/* 垂直居中 */
right: 0;
top: 50%;
margin-top: -18px;
/* 按钮居中 */
text-align: center;
line-height: 36px;
/* 去除下划线 */
text-decoration: none;
color: #fff;
width: 25px;
height: 36px;
/* 设置透明 */
background-color: rgba(0,0,0,.3);
/* 圆角边框 */
border-top-left-radius: 18px;
border-bottom-left-radius: 18px;
}
.promo-nav {
position: absolute;
/* 绝对定位的盒子水平居中 */
bottom: 16px;
left: 50%;
margin-left: -44px;
width: 88px;
height: 17px;
/* 白色透明 */
background-color: rgba(255,255,255,.3);
/* 圆角边框 */
border-radius: 8px;
}
.promo-nav li {
float: left;
margin: 3px;
width: 10px;
height: 10px;
background-color: #fff;
border-radius: 50%;
}
.promo-nav .first {
margin-left: 6px;
background-color: #ff5000;
}
</style>
效果
: