命名:
1大盒子我们类名为:tb-promo 淘宝广告
2里面先放一张图片
3左右两个按钮用链接就好了 左箭头prev 右箭头 next
4底侧小圆点ul继续做。类名为promo-nav
<!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>
<style>
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
.tb-promo {
position: relative;
width: 520px;
height: 280px;
background-color: pink;
margin: 200px auto;
}
.tb-promo img {
width: 520px;
height: 280px;
}
/* 并集选择器可以集体声明相同的样式 */
.perv,
.next {
position: absolute;
/* 绝对定位的盒子垂直居中 */
top: 50%;
margin-top: -15px;
/* 加了绝对定位的盒子可以直接设置高度和宽度 */
width: 20px;
height: 30px;
background: rgba(0, 0, 0, .3);
color: white;
text-align: center;
line-height: 30px;
text-decoration: none;
}
.perv {
left: 0;
border-radius: 0 15px 15px 0;
}
.next {
/* 如果一个盒子既有left属性也有right属性,则默认会执行left */
/* 同理 top和bottom一起时先执行top */
right: 0;
border-radius: 15px 0px 0px 15px;
}
.promo-nav {
position: absolute;
bottom: 15px;
left: 0;
width: 70px;
height: 13px;
background: rgba(255, 255, 255, .3);
border-radius: 6px;
/* 水平居中 */
left: 50%;
margin-left: -35px;
}
.promo-nav li {
float: left;
margin: 3px 3px;
width: 8px;
height: 8px;
background-color: white;
border-radius: 4px;
}
.tb-promo .promo-nav .selected {
background-color: #ff5000;
}
</style>
</head>
<body>
<div class="tb-promo">
<img src="images/tb.jpg" alt="">
<!-- 左侧按钮 -->
<a href="#" class="perv">></a>
<!-- 右侧按钮 -->
<a href="#" class="next">></a>
<!-- 小圆点 -->
<ul class="promo-nav">
<li class="selected"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>