原生js轮播图
XML/HTML Code
- <div class="banner">
- <div class="prev"><</div>
- <div class="next">></div>
- <ul>
- <li><a href="javacsript:;"><img src="../dalian.jpg" alt=""></a></li>
- <li><a href="javacsript:;"><img src="../dandong.jpg" alt=""></a></li>
- <li><a href="javacsript:;"><img src="../sanya.jpg" alt=""></a></li>
- <li><a href="javacsript:;"><img src="../dandong.jpg" alt=""></a></li>
- </ul>
- <div class="gd">
- </div>
- </div>
CSS Code
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- .banner {
- position: relative;
- overflow: hidden;
- margin: 90px auto;
- width: 520px;
- height: 280px;
- background-color: aqua;
- border-radius: 12px;
- }
- li {
- list-style: none;
- }
- .banner ul {
- position: absolute;
- top: 0;
- left: 0;
- }
- .banner ul li {
- float: left;
- }
- .banner ul li a img {
- display: block;
- width: 520px;
- height: 280px;
- }
- .banner .prev,
- .banner .next {
- display: none;
- z-index: 2;
- position: absolute;
- width: 50px;
- height: 35px;
- line-height: 35px;
- border-radius: 17.5px;
- top: 50%;
- background-color: rgba(0, 0, 0, .2);
- color: #fff;
- font-size: 18px;
- font-weight: 700;
- }
- .banner .prev {
- left: 0;
- transform: translate(-50%, -50%);
- text-indent: 28px;
- }
- .banner .next {
- rightright: 0;
- transform: translate(50%, -50%);
- text-indent: 8px;
- }
- .banner .prev:hover,
- .banner .next:hover {
- background-color: rgba(0, 0, 0, .3);
- }
- .banner .gd {
- position: absolute;
- left: 50%;
- bottombottom: 20px;
- margin-left: -36.5px;
- display: flex;
- justify-content: space-around;
- width: 75px;
- height: 15px;
- border-radius: 8px;
- background-color: #ffffff4d;
- }
- .banner .gd i {
- display: block;
- width: 10px;
- height: 10px;
- border-radius: 50%;
- margin-top: 2.5px;
- background-color: azure;
- }
- .current {
- background-color: #ff5000 !important;
- width: 15px !important;
- height: 9px !important;
- border-radius: 4.5px !important;
- }
- </style>
原文地址:http://www.freejs.net/article_jiaodiantu_935.html