jQuery和CSS3 3D多维数据集页面滑块

  • 源码大小:8.23KB
  • 所需积分:1积分
  • 源码编号:19JP-3474
  • 浏览次数:1021次
  • 最后更新:2023年06月17日
  • 所属栏目:滑块
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

一个由jQuery和CSS3转换和转换组成的全屏3D立方体页面滑块。它具有奇特的页面滑块效果,在页面之间平滑过渡,同时它们在3D空间中相互重叠

如何使用它:

1.为页面滑块创建页面(内容部分)。

  1. <div id="wrap">
  2. <div class="cube">
  3. <section class="page active face front" id="home">
  4. <div class="act-table text-center">
  5. <div class="act-table-cell ver-middle">Home Page</div>
  6. </div>
  7. </section>
  8. <section class="page face back" id="portfolio">
  9. <div class="act-table text-center">
  10. <div class="act-table-cell ver-middle">Portfolio Page</div>
  11. </div>
  12. </section>
  13. <section class="page face top" id="about">
  14. <div class="act-table text-center">
  15. <div class="act-table-cell ver-middle">about Page</div>
  16. </div>
  17. </section>
  18. <section class="page face right" id="contact">
  19. <div class="act-table text-center">
  20. <div class="act-table-cell ver-middle">contact Page</div>
  21. </div>
  22. </section>
  23. <section class="page face bottom" id="blog">
  24. <div class="act-table text-center">
  25. <div class="act-table-cell ver-middle">blog Page</div>
  26. </div>
  27. </section>
  28. <section class="page face left" id="article">
  29. <div class="act-table text-center">
  30. <div class="act-table-cell ver-middle">article Page</div>
  31. </div>
  32. </section>
  33. </div>
  34. </div>

2.创建一个页眉导航,使您可以在这些页面中导航。

  1. <header>
  2. <nav class="text-center">
  3. <ul class="inline-block">
  4. <li class="pull-left active"><a href="#" data-direction="front">Home</a></li>
  5. <li class="pull-left"><a href="#" data-direction="back">Portfolio</a></li>
  6. <li class="pull-left"><a href="#" data-direction="top">About</a></li>
  7. <li class="pull-left"><a href="#" data-direction="right">Contact</a></li>
  8. <div class="clearfix"></div>
  9. </ul>
  10. </nav>
  11. </header>

3.将以下CSS片段复制并粘贴到您的页面中。

  1. /* header nav styles */
  2. header {
  3. position: fixed;
  4. top: 8px;
  5. left: 0;
  6. right: 0;
  7. z-index: 100;
  8. transition: 1s;
  9. -webkit-transition: 1s;
  10. -moz-transition: 1s
  11. }
  12.  
  13. header.go-out {
  14. top: -150px
  15. }
  16.  
  17. header nav ul {
  18. background-color: rgba(255, 255, 255, 0.2);
  19. overflow: hidden;
  20. border-radius: 5px;
  21. -webkit-border-radius: 5px;
  22. -moz-border-radius: 5px
  23. }
  24.  
  25. header nav ul li {
  26. color: #fff
  27. }
  28.  
  29. header nav ul li a {
  30. width: 100px;
  31. max-width: 150px;
  32. height: 32px;
  33. display: block;
  34. padding-top: 13px
  35. }
  36.  
  37. header nav ul li.active a,
  38. header nav ul li.active a:hover {
  39. background-color: rgba(255, 255, 255, 0.2)
  40. }
  41.  
  42. header nav ul li:hover a {
  43. background-color: rgba(255, 255, 255, 0.1)
  44. }
  45.  
  46. /* page styles */
  47. .page {
  48. background-color: rgba(0, 0, 0, 0.2)
  49. }
  50.  
  51. .page .act-table {
  52. width: 100%;
  53. height: 100%
  54. }
  55.  
  56. .page .act-table .act-table-cell {
  57. font-size: 100px;
  58. font-weight: 500;
  59. color: #fff
  60. }
  61.  
  62. .page.active {
  63. z-index: 50
  64. }
  65.  
  66. #wrap {
  67. position: fixed;
  68. top: 0;
  69. bottom: 0;
  70. right: 0;
  71. left: 0;
  72. transition: .8s;
  73. -webkit-transition: .8s;
  74. -moz-transition: .8s
  75. }
  76.  
  77. #wrap.active {
  78. top: 10%;
  79. bottom: 10%;
  80. right: 10%;
  81. left: 10%
  82. }
  83.  
  84. .cube {
  85. position: relative;
  86. width: 100%;
  87. height: 100%;
  88. transform-style: preserve-3d;
  89. transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  90. -webkit-transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  91. -moz-transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  92. transition: 1s;
  93. -webkit-transition: 1s;
  94. -moz-transition: 1s
  95. }
  96.  
  97. .cube.reverse-back {
  98. transform: rotateX(180deg) rotateY(0deg) rotateZ(-180deg);
  99. -webkit-transform: rotateX(180deg) rotateY(0deg) rotateZ(-180deg);
  100. -moz-transform: rotateX(180deg) rotateY(0deg) rotateZ(-180deg)
  101. }
  102.  
  103. .cube.reverse-back .back {
  104. transform: translateZ(-800px) rotateY(-180deg);
  105. -webkit-transform: translateZ(-800px) rotateY(-180deg);
  106. -moz-transform: translateZ(-800px) rotateY(-180deg)
  107. }
  108.  
  109. .cube.reverse-left .left {
  110. transform: translateX(-800px) rotateY(-90deg);
  111. -webkit-transform: translateX(-800px) rotateY(-90deg);
  112. -moz-transform: translateX(-800px) rotateY(-90deg)
  113. }
  114.  
  115. .cube.reverse-right {
  116. transform: rotateX(0deg) rotateY(270deg) rotateZ(0deg);
  117. -webkit-transform: rotateX(0deg) rotateY(270deg) rotateZ(0deg);
  118. -moz-transform: rotateX(0deg) rotateY(270deg) rotateZ(0deg)
  119. }
  120.  
  121. .cube.reverse-right .right {
  122. transform: translateX(800px) rotateY(90deg);
  123. -webkit-transform: translateX(800px) rotateY(90deg);
  124. -moz-transform: translateX(800px) rotateY(90deg)
  125. }
  126.  
  127. .cube.reverse-top {
  128. transform: rotateX(-90deg) rotateY(0deg) rotateZ(0deg);
  129. -webkit-transform: rotateX(-90deg) rotateY(0deg) rotateZ(0deg);
  130. -moz-transform: rotateX(-90deg) rotateY(0deg) rotateZ(0deg)
  131. }
  132.  
  133. .cube.reverse-top .top {
  134. transform: translateY(-400px) rotateX(90deg);
  135. -webkit-transform: translateY(-400px) rotateX(90deg);
  136. -moz-transform: translateY(-400px) rotateX(90deg)
  137. }
  138.  
  139. .cube.reverse-bottom .bottom {
  140. transform: translateY(400px) rotateX(-90deg);
  141. -webkit-transform: translateY(400px) rotateX(-90deg);
  142. -moz-transform: translateY(400px) rotateX(-90deg)
  143. }
  144.  
  145. .face {
  146. display: block;
  147. position: absolute;
  148. top: 0;
  149. bottom: 0;
  150. left: 0;
  151. right: 0;
  152. width: 100%;
  153. height: 100%;
  154. color: #666;
  155. font-size: 18px;
  156. text-align: center;
  157. box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5);
  158. -webkit-box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5);
  159. -moz-box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5)
  160. }
  161.  
  162. .front {
  163. background-color: #28aadc
  164. }
  165.  
  166. .front.active {
  167. transform: translateZ(800px);
  168. -webkit-transform: translateZ(800px);
  169. -moz-transform: translateZ(800px)
  170. }
  171.  
  172. .back {
  173. background-color: #ff3366
  174. }
  175.  
  176. .back:not(.active) {
  177. transform: translateZ(-800px) rotateY(-180deg);
  178. -webkit-transform: translateZ(-800px) rotateY(-180deg);
  179. -moz-transform: translateZ(-800px) rotateY(-180deg)
  180. }
  181.  
  182. .back .active {
  183. transform: translateZ(800px);
  184. -webkit-transform: translateZ(800px);
  185. -moz-transform: translateZ(800px)
  186. }
  187.  
  188. .left:not(.active) {
  189. transform: translateX(-800px) rotateY(-90deg);
  190. -webkit-transform: translateX(-800px) rotateY(-90deg);
  191. -moz-transform: translateX(-800px) rotateY(-90deg)
  192. }
  193.  
  194. .left .active {
  195. transform: translateZ(800px);
  196. -webkit-transform: translateZ(800px);
  197. -moz-transform: translateZ(800px)
  198. }
  199.  
  200. .right {
  201. background-color: #000
  202. }
  203.  
  204. .right:not(.active) {
  205. transform: translateX(800px) rotateY(90deg);
  206. -webkit-transform: translateX(800px) rotateY(90deg);
  207. -moz-transform: translateX(800px) rotateY(90deg)
  208. }
  209.  
  210. .right .active {
  211. transform: translateZ(800px);
  212. -webkit-transform: translateZ(800px);
  213. -moz-transform: translateZ(800px)
  214. }
  215.  
  216. .top {
  217. background-color: #FFAD33
  218. }
  219.  
  220. .top:not(.active) {
  221. transform: translateY(-400px) rotateX(90deg);
  222. -webkit-transform: translateY(-400px) rotateX(90deg);
  223. -moz-transform: translateY(-400px) rotateX(90deg)
  224. }
  225.  
  226. .top .active {
  227. transform: translateZ(800px);
  228. -webkit-transform: translateZ(800px);
  229. -moz-transform: translateZ(800px)
  230. }
  231.  
  232. .bottom:not(.active) {
  233. transform: translateY(400px) rotateX(-90deg);
  234. -webkit-transform: translateY(400px) rotateX(-90deg);
  235. -moz-transform: translateY(400px) rotateX(-90deg)
  236. }
  237.  
  238. .bottom .active {
  239. transform: translateZ(800px);
  240. -webkit-transform: translateZ(800px);
  241. -moz-transform: translateZ(800px)
  242. }

4.在文档末尾加载最新的jQuery库。

  1. <script src="/path/to/cdn/jquery.slim.min.js"></script>

5.激活三维立方体页面滑块。

  1. (function(document, window, $){
  2. $(document).ready(function(){
  3. var
  4. windowWidth = $(window).width(),
  5. windowHeight = $(window).height(),
  6. $header = $('header');
  7. function headerAnchors(){
  8. var pageDirection = '';
  9. var thisElement;
  10. var timeout;
  11. $header.find('nav li a').click(function(event){
  12. event.preventDefault();
  13. $('.cube').removeClass('reverse-' + pageDirection);
  14. thisElement = $(this);
  15. pageDirection = thisElement.data('direction');
  16. reverseDirection = thisElement.data('reverse-direction');
  17. thisElement.parent().addClass('active').siblings().removeClass('active');
  18. $('.cube').addClass('reverse-' + pageDirection);
  19.  
  20. $header.addClass('go-out');
  21. $('#wrap').addClass('active');
  22. clearTimeout(timeout);
  23. timeout = setTimeout(function(){
  24. $header.removeClass('go-out');
  25. $('#wrap').removeClass('active');
  26. }, 1000);
  27. });
  28. }headerAnchors();
  29. $(window).resize(function(){
  30. windowWidth = $(window).width();
  31. windowHeight = $(window).height();
  32. });
  33. });
  34. })(document, window, jQuery);

预览截图