原生JS实现图片自动轮播缓冲切换特效,很实用流畅的图片轮播特效,在较现代的浏览器上展现的圆角效果,兼容差点的是直角效果,全部原生JS实现,还是很不错的值得大家学习并利用,推荐下载。
使用方法:
分别引用css文件和js文件 如:
<link type="text/css" href="https://www.jb51.net/css/photoSlider.min.css" /> <script src="https://www.jb51.net/js/photoSlider.min.js" type="text/javascript" charset="utf-8"></script>
html:
<li><a href="https://www.jb51.net/"><img src="https://www.jb51.net/img/1.jpg" /></a></li> <li><a href="https://www.jb51.net/"><img src="https://www.jb51.net/img/2.jpg" /></a></li> <li><a href="https://www.jb51.net/"><img src="https://www.jb51.net/img/3.jpg" /></a></li>
javascript:
window.onload=function(){ photoSlide({ wrap: document.getElementById('photo'),//最外层容器 loop: true,//设置无缝循环 autoPlay:true,//自动轮播 autoTime:4000,//轮播时间间隔 pagination:true //点状态列表 }); }
完整示例:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <title>photoSlider-纯js移动开发轮播图、相册滑动插件</title> <meta content="javascript移动端相册轮播图手指滑动插件" /> <meta content="javascript移动端相册轮播图手指滑动插件,支持自定义轮播图滑动属性" /> <meta name=apple-mobile-web-app-title content="photoSlider"> <meta content="yes" /> <meta content="black" /> <meta name=renderer content=webkit> <meta content="yes"> <meta content="application"> <meta content="true"> <meta content="app"> <link type="text/css" href="https://www.jb51.net/css/photoSlider.min.css" /> </head> <body> <div> <div> <div></div> <div></div> <div></div> </div> <ul> <li><a href="https://www.jb51.net/"><img src="https://www.jb51.net/img/1.jpg" /></a></li> <li><a href="https://www.jb51.net/"><img src="https://www.jb51.net/img/2.jpg" /></a></li> <li><a href="https://www.jb51.net/"><img src="https://www.jb51.net/img/3.jpg" /></a></li> </ul> </div> </body> </html> <script src="https://www.jb51.net/js/photoSlider.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> document.onreadystatechange = subSomething; function subSomething() { if (document.readyState == 'complete') { setTimeout(function(){ var load=document.getElementById('loading'); load.style.opacity=0; document.getElementById('pic-view').setAttribute('class','pic-view show'); load.remove(); },500); } } window.onload=function(){ photoSlide({ wrap: document.getElementById('photo'), loop: true, autoPlay:true, autoTime:4000, pagination:true }); } </script>
以上所述就是本文的全部内容了,希望大家能够喜欢。
您可能感兴趣的文章: