标签:overflow inter highlight lin osi size .sh padding center
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title> 广告图片轮播切换</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="adver"> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul> <div class="arrowLeft"><</div> <div class="arrowRight">></div> </div> </body> </html>
<script src="js/jquery-3.2.1.js" type="text/javascript"></script> <script> $(document).ready(function () { $(".adver").mouseover(function () { $(".arrowLeft").show(); $(".arrowRight").show(); }).mouseout(function () { $(".arrowLeft").hide(); $(".arrowRight").hide(); }) var i = 0; var path = ["adver01.jpg", "adver02.jpg", "adver03.jpg", "adver04.jpg", "adver05.jpg", "adver06.jpg"]; $(".arrowRight").click(function () { if (i == path.length - 1) { i=0; } else { i++; var str = "images/" + path[i]; $(".adver").css({"background": "url(" + str + ")"}); $("li:nth-of-type("+(i+1)+")").css({"background":"orange"}); $("li:nth-of-type("+(i+1)+")").siblings().css({"background":"#333"}); } }) $(".arrowLeft").click(function () { if (i == 0) { i=6; } else { i--; var str = "images/" + path[i]; $(".adver").css({"background": "url(" + str + ")"}); $("li:nth-of-type("+(i+1)+")").css({"background":"orange"}); $("li:nth-of-type("+(i+1)+")").siblings().css({"background":"#333"}); } }) }) </script>
ul,li{padding: 0;margin: 0; list-style: none;} .adver{margin: 0 auto; width: 700px; overflow: hidden; height: 454px; position: relative; background: url("../images/adver01.jpg");} ul{position: absolute; bottom:10px; z-index: 100; width: 100%; text-align: center;} ul li{display: inline-block; font-size: 10px; line-height: 20px; font-family: "微软雅黑"; margin: 0 1px; width: 20px; height: 20px; border-radius: 50%; background: #333333; text-align: center; color: #ffffff;} .arrowLeft,.arrowRight{ position: absolute; width: 30px; background:rgba(0,0,0,0.2); height: 50px; line-height: 50px; text-align: center; top:200px; z-index: 150; font-family: "微软雅黑"; font-size: 28px; font-weight: bold; cursor: pointer; display: none; } .arrowLeft{left: 10px;} .arrowRight{right: 10px;} li:nth-of-type(1){ background: orange; }
标签:overflow inter highlight lin osi size .sh padding center
原文地址:http://www.cnblogs.com/binglong180/p/7623566.html