jquery实现三维螺旋过渡切换幻灯片效果代码
代码语言:html
所属分类:幻灯片
代码描述:jquery实现三维螺旋过渡切换幻灯片效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style type="text/css"> html,body,div{ margin: 0; padding: 0; } body{background-color: #232323} .slider-outer{ width: 560px; height: 300px; margin: 150px auto; background-color: #f60; position: relative; } .img-item{ position: absolute; width: 112px; height: 100%; background-color: #f10; transition: all 1.5s; /*设置子元素在3D空间中呈现*/ transform-style: preserve-3d; } /*让图片可以构成一个有四个面的长方体 start*/ .img{ width: 100%; height: 100%; position: absolute; background-size: cover; } .img:nth-child(1){ background: url(//repo.bfw.wiki/bfwrepo/image/5e0c6f477f6ac.png) no-repeat; transform: rotateX(0deg) translateZ(150px); } .img:nth-child(2){ background: url(//repo.bfw.wiki/bfwrepo/image/5fc1a7f99e34f.png) no-repeat; transform: rotateX(-90deg) translateZ(150px); } .img:nth-child(3){ background: url(//repo.bfw.wiki/bfwrepo/image/609636b3b27fe.png) no-repeat; transform: rotateX(-180deg) translateZ(150px); } .img:nth-child(4){ background: url(//repo.bfw.wiki/bfwrepo/image/5fc8aa82a7330.png) no-repeat; transform: rotateX(-270deg) translateZ(150px); } /*让图片可以构成一个有四个面的长方体 end*/ .btns{ position: absolute; top: 50%; width: 100%; height: 70px; margin-top: -35px; } .prev, .next{ width: 70px; height: 70px; line-height: 70px; text-align: center; background-color: rgba(0,0,0,.3); color: #fff; font-size: 30px; cursor: pointer; position: absolute; } .prev{ left: 0; } .next{ right: 0; } </style> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script> <script type="text/javascript"> $(function (){ var num = 0; $("#j_silder_outer .img-item").each(function(index, el) { $(this).css({ "left":$(this).width() * index + "px", /*让每个img-item延时一定时间执行动画*/ "transitionDelay": index * 0.3 + "s" }); $(this).find(".img").css({ "backgroundPosition": -$(this).width() * index + "px" });; }); $(".prev").on("click",function (){ $("#j_silder_outer .img-item".........完整代码请登录后点击上方下载按钮下载查看
网友评论0