迅速建立微信小程序_原生JS完成层叠轮播图

原生JS实现层叠轮播图       这篇文章主要为大家详细介绍了原生JS层叠轮播图,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

又是轮播?没错,换个样式玩轮播。

HTML:

 !DOCTYPE html 
 html lang="en" 
 head 
 meta charset="UTF-8" 
 title wtf /title 
 /head 
 body 
 div 
 div 
 img src="img/A.jpg" alt="PIC" 
 img src="img/B.jpg" alt="PIC" 
 img src="img/C.jpg" alt="PIC" 
 div 
 span /span 
 span /span 
 /div 
 /div 
 /div 
 /body 
 /html 

CSS:

 style 
 .box {width: 1200px; height: 300px; transform-style: perserve-3d; margin: 50px auto; position: relative;}
 .box img{width:600px; position: absolute; top: 60px; transition:all .3s linear;}
 .box:hover .btn{opacity: 1;}
 .front {left: 0px;}
 .back {left: 600px;} 
 .active {left: 300px; transform: scale(1.5); z-index: 10;}
 .btns .btn {width: 60px; height: 60px; display: block; position: absolute; background-color: rgba(0,0,0,.5); font-size: 50px; font-family: "微软雅黑"; color:rgba(255,255,255,.5); line-height: 55px; text-align: center; cursor: pointer; z-index: 100; opacity: 0; transition:opacity .3s linear;} 
 .btns .btn:first-child {top: 125px;}
 .btns .btn:last-child {top: 125px; right: 0px;}
 /style 

JS:

 script 
 onload = function(){
 var btns = document.getElementsByClassName('btn'),
 imgs = document.getElementsByClassName('box')[0].getElementsByTagName('img');
 var index = 2,
 front = 0,
 back = 0,
 offset = false,
 timer = setInterval(timer,5000);

相关阅读