effect
![Insert picture description here](https://img-blog.csdnimg.cn/20200808180037720.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTAxOTgzMA==,size_16,color_FFFFFF,t_70)
analysis
![Insert picture description here](https://img-blog.csdnimg.cn/2020080818005340.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTAxOTgzMA==,size_16,color_FFFFFF,t_70)
- Our class name for Big Box is: tb-promo Taobao ads
- Put a picture inside.
- Just use links for the left and right buttons. Left arrow prev right arrow next
- Then the big box uses relative positioning, and the button uses absolute positioning.
- How to do vertical centering?
Take the left button as an example: left: 0 top: 50% margin-top: 15px
- The small dot ul on the bottom side continues to do it. The class name is promo-nav
- The box at the bottom is still positioned absolutely, and the horizontal centering method is similar to the centering method of the button.
- The dots are made with ul, and the dots are arranged in a row by floating.
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
.tb-promo {
position: relative;
width: 520px;
height: 280px;
background-color: pink;
margin: 100px auto;
}
.tb-promo img {
width: 520px;
height: 280px;
}
.next,
.prev {
position: absolute;
top: 50%;
margin-top: -15px;
width: 20px;
height: 30px;
background-color: rgba(0, 0, 0, .3);
color:white;
text-align: center;
line-height: 30px;
text-decoration: none;
}
.prev {
left: 0px;
border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
}
.next {
right: 0px;
border-top-left-radius: 15px;
border-bottom-left-radius: 15px;
}
.promo-nav {
position: absolute;
bottom: 15px;
left: 50%;
margin-left: -35px;
width: 70px;
height: 13px;
background-color: rgba(255, 255, 255, .3);
border-radius: 7px;
}
.promo-nav li {
float:left;
width: 8px;
height: 8px;
background-color: white;
border-radius: 50%;
margin: 3px;
}
</style>
<body>
<div class="tb-promo">
<img src="pic.jpg" alt="图片">
<a href="#" class="prev"><</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>