3D轮播图
Posted tuziling
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了3D轮播图相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> * { padding: 0; margin: 0; list-style: none; } .view { width: 560px; height: 300px; margin: 100px auto; position: relative; } ul { width: 100%; height: 100%; transform-style: preserve-3d; transform: rotate3d(1, 1, 0, 0deg); } ul>li { width: 20%; height: 100%; float: left; transform-style: preserve-3d; position: relative; /* 过度效果 */ transition: transform 0.6s; } ul>li>span { width: 100%; height: 100%; position: absolute; left: 0; top: 0; } ul>li>span:nth-of-type(1) { background: url("./images/q1.jpg"); /* 往z轴正方向偏移 */ transform: translateZ(150px); } ul>li>span:nth-of-type(2) { background: url("./images/q2.jpg"); transform: translateY(-150px) rotateX(90deg); } ul>li>span:nth-of-type(3) { background: url("./images/q3.jpg"); transform: translateZ(-150px) rotateX(-180deg); } ul>li>span:nth-of-type(4) { background: url("./images/q4.jpg"); transform: translateY(150px) rotateX(-90deg); } ul>li:nth-of-type(2)>span { background-position-x: -100%; } ul>li:nth-of-type(3)>span { background-position-x: -200%; } ul>li:nth-of-type(4)>span { background-position-x: -300%; } ul>li:nth-of-type(5)>span { background-position-x: -400%; } .pre, .next { width: 40px; height: 60px; font-size: 40px; position: absolute; top: 50%; text-decoration: none; text-align: center; line-height: 60px; color: #ccc; background-color: rgba(0, 0, 0, 0.4); transform: translate(0, -50%); } .pre { left: 0; } .next { right: 0; } </style> </head> <body> <div class="view"> <ul> <li> <span></span> <span></span> <span></span> <span></span> </li> <li> <span></span> <span></span> <span></span> <span></span> </li> <li> <span></span> <span></span> <span></span> <span></span> </li> <li> <span></span> <span></span> <span></span> <span></span> </li> <li> <span></span> <span></span> <span></span> <span></span> </li> </ul> <a href="javascript:;" class="pre" id="pre"><</a> <a href="javascript:;" class="next" id="next">></a> </div> <script src="./js/jquery-3.1.0.js"></script> <script> $(function () { var index = 0 var flag = true; //右箭头 $("#next").on("click", function () { if (flag == true) { flag = false; index--; $("li").each(function (key, value) { $(this).css({ "transform": "rotateX(" + (index * 90) + "deg)", "transition-delay": (key * 0.2) + "s" }); }); setTimeout(function () { flag = true; }, 1000); } }); //左箭头 $("#pre").on("click", function () { if (flag == true) { flag = false; index++; $("li").each(function (key, value) { $(this).css({ "transform": "rotateX(" + (index * 90) + "deg)", "transition-delay": (key * 0.2) + "s" }); }); setTimeout(function () { flag = true; }, 1000) } }) }) </script> </body> </html>
以上是关于3D轮播图的主要内容,如果未能解决你的问题,请参考以下文章