<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Shunfeng</title> <style> * { margin: 0; padding: 0; } li { list-style: none; } .tb { width: 520px; height: 280px; margin: 100px auto; position: relative; } .tb a { width: 24px; height: 36px; display: block; position:absolute; top:50%; margin-top: -18px; } .left { left:0; background:url(images/left.png) no-repeat; } .right { right:0; background:url(images/right.png) no-repeat; } .tb ul { width: 70px; height: 13px; background-color: red; position: absolute; bottom: 20px; left:50%; /* 走父容器的一半 */ margin-left: -35px; /* 走自己的一半 */ background-color:rgba(255,255,255,.3); border-radius: 5px; } .tb ul li { width: 8px; height: 8px; background-color: #fff; float: left; margin: 3px; border-radius: 50%; } .tb.current { background-color:#f40; } </style> </head> <body> <div class="tb"> <img src="images/tb.jpg"alt=""> <a href="" class="left"></a> <a href="" class="right"></a> <ul> <li class="current"></li> <li></li> <li></li> <li></li> <li></li> </ul> </div> </body> </html>
效果图如下:
注意几个问题:
一个是定位的问题,另一个是优先级的问题。