轮播图写法一:定位
| <!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>Document</title> |
| <style> |
| *{ |
| padding: 0; |
| margin: 0; |
| list-style: none; |
| text-decoration: none; |
| } |
| #wrap{ |
| width: 590px; |
| height: 470px; |
| margin: 50px auto; |
| border: 10px red solid; |
| position: relative; |
| } |
| img{ |
| vertical-align: middle; |
| } |
| |
| |
| .imgs>img{ |
| position: absolute; |
| } |
| .imgs>img:nth-child(4){ |
| z-index: 3; |
| } |
| .piont{ |
| position: absolute; |
| left: 30px; |
| bottom: 20px; |
| z-index:99; |
| } |
| .piont>a{ |
| display: inline-block; |
| width: 10px; |
| height: 10px; |
| border-radius: 50%; |
| background-color: rgb(243,206,139); |
| margin: 0 3px; |
| border: 2px solid transparent; |
| |
| background-clip: content-box; |
| } |
| .piont>a:hover{ |
| background-color: #fff; |
| border: 2px solid rgb(100,100,109); |
| } |
| </style> |
| </head> |
| <body> |
| |
| |
| |
| |
| |
| |
| |
| <div id="wrap"> |
| |
| <div class="imgs"> |
| <img src="./img/1.jpg" alt=""> |
| <img src="./img/2.jpg" alt=""> |
| <img src="./img/3.jpg" alt=""> |
| <img src="./img/4.jpg" alt=""> |
| <img src="./img/5.jpg" alt=""> |
| </div> |
| |
| <div class="piont"> |
| <a href="#"></a> |
| <a href="#"></a> |
| <a href="#"></a> |
| <a href="#"></a> |
| <a href="#"></a> |
| </div> |
| </div> |
| |
| |
| </body> |
| </html> |
复制
轮播图写法二:float
| <!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>Document</title> |
| |
| <style> |
| *{ |
| padding: 0; |
| margin: 0; |
| list-style: none; |
| text-decoration: none; |
| } |
| #wrap{ |
| width: 590px; |
| height: 470px; |
| margin: 50px auto; |
| |
| overflow: hidden; |
| position: relative; |
| } |
| img{ |
| vertical-align: middle; |
| } |
| .imgs{ |
| width: 2950px; |
| } |
| .imgs>img{ |
| float: left; |
| } |
| .piont{ |
| position: absolute; |
| left: 30px; |
| bottom: 20px; |
| } |
| .piont>a{ |
| display: inline-block; |
| width: 10px; |
| height: 10px; |
| border-radius: 50%; |
| background-color: rgb(243,206,139); |
| margin: 0 3px; |
| border: 2px solid transparent; |
| |
| background-clip: content-box; |
| } |
| .piont>a:hover{ |
| background-color: #fff; |
| border: 2px solid rgb(100,100,109); |
| } |
| </style> |
| </head> |
| <body> |
| |
| |
| |
| |
| |
| |
| |
| <div id="wrap"> |
| |
| <div class="imgs"> |
| <img src="./img/1.jpg" alt=""> |
| <img src="./img/2.jpg" alt=""> |
| <img src="./img/3.jpg" alt=""> |
| <img src="./img/4.jpg" alt=""> |
| <img src="./img/5.jpg" alt=""> |
| </div> |
| |
| <div class="piont"> |
| <a href="#"></a> |
| <a href="#"></a> |
| <a href="#"></a> |
| <a href="#"></a> |
| <a href="#"></a> |
| </div> |
| |
| <div> |
| <span></span> |
| <span></span> |
| </div> |
| </div> |
| |
| |
| </body> |
| </html> |
复制
轮播图写法三:swiper
| <!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>Document</title> |
| |
| |
| |
| <link rel="stylesheet" href="./swiper/swiper-bundle.css" /> |
| <style> |
| |
| .swiper { |
| width: 590px; |
| height: 480px; |
| margin: 50px auto; |
| } |
| |
| |
| |
| |
| |
| .swiper-pagination-bullet{ |
| background-color: turquoise; |
| width: 20px; |
| height: 20px; |
| |
| } |
| </style> |
| </head> |
| <body> |
| |
| <div class="swiper"> |
| |
| <div class="swiper-wrapper"> |
| <div class="swiper-slide"> |
| <img src="./img/1.jpg" alt="" /> |
| </div> |
| <div class="swiper-slide"> |
| <img src="./img/2.jpg" alt="" /> |
| </div> |
| <div class="swiper-slide"> |
| <img src="./img/3.jpg" alt="" /> |
| </div> |
| </div> |
| |
| <div class="swiper-pagination"></div> |
| |
| |
| <div class="swiper-button-prev"></div> |
| <div class="swiper-button-next"></div> |
| </div> |
| |
| |
| <script src="./swiper/swiper-bundle.js"></script> |
| |
| <script> |
| var mySwiper = new Swiper(".swiper", { |
| |
| |
| |
| loop: true, |
| effect: 'cards', |
| |
| |
| pagination: { |
| el: ".swiper-pagination", |
| clickable :true, |
| }, |
| |
| |
| navigation: { |
| nextEl: ".swiper-button-next", |
| prevEl: ".swiper-button-prev", |
| }, |
| }); |
| </script> |
| </body> |
| </html> |
复制