利用swiper开发轮播图效果
时间:6年前 阅读:5075
直接上代码:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="../uu/swiper-4.4.1.min.css"> <style type="text/css"> .swiper-container { width: 590px; height: 470px; border: 1px solid darkcyan; margin: 100px auto; } .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet { margin: 0 4px; background: transparent; width: 8px; height: 8px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.8); position: relative; transition: all 0.5; /*监控淡入淡出效果*/ } /*:after在后面加. 光晕效果*/ .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet:after{ content: ''; width: 18px; height: 18px; background: white; opacity: 1; border-radius: 50%; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: -1; transition: all 0.5; /*监控淡入淡出效果*/ } .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet.swiper-pagination-bullet-active { background: white; /*outline: 3px solid rgba(255,255,255,0.3);*/ border: 2px solid white; /*border-radius: 50%;这个是对它是无效的*/ /*-moz-outline-radius: 9px; 变圆角 -moz- 只有火狐识别这个*/ } /*:after在后面加. o激活下的 光晕效果*/ .swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet.swiper-pagination-bullet-active:after{ opacity: 0.3; } </style> </head> <body> <div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide"><img src="https://www.qiquanji.com/data/img/dmj/201903041551667331565510.jpg"/></div> <div class="swiper-slide"><img src="https://www.qiquanji.com/data/img/dmj/201903041551667332173447.jpg"/></div> <div class="swiper-slide"><img src="https://www.qiquanji.com/data/img/dmj/201903041551667332340393.jpg"/></div> <div class="swiper-slide"><img src="https://www.qiquanji.com/data/img/dmj/201903041551667332182609.jpg"/></div> <div class="swiper-slide"><img src="https://www.qiquanji.com/data/img/dmj/201903041551667332190735.jpg"/></div> </div> <!-- 如果需要分页器 --> <div class="swiper-pagination"></div> <!-- 如果需要导航按钮 --> <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> </div> <script src="../uu/swiper-4.4.1.min.js"></script> <script> var mySwiper = new Swiper ('.swiper-container', { // direction: 'vertical', // 垂直切换选项 direction: 'horizontal', //横切换选项 loop: true, // 循环模式选项 // 如果需要分页器 pagination: { el: '.swiper-pagination', clickable :true, //点击小圆点 }, // 如果需要前进后退按钮 navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, //autoplay:true,自动切换 //等同于以下设置 autoplay: { delay: 3000, stopOnLastSlide: false, disableOnInteraction: true, }, }); </script> </body> </html>
代码最终效果点击上面的运行代码来看
本站声明:网站内容来源于网络,如有侵权,请联系我们https://www.qiquanji.com,我们将及时处理。
微信扫码关注
更新实时通知
网友评论