布局框架

简洁全屏项目列表滑动面板UI设计

阿里云


这是一款简洁时尚的全屏项目列表滑动面板 UI 设计效果。该项目菜单列表开始以缩略图的方式全屏垂直排列,当用户点击了相应的缩略图之后,其它缩略图面板向上滑动,将该项目的内容全部显露出来。

HTML 结构

该全屏项目列表滑动面板的 HTML 结果包括 2 个无序列表。ul.cd-projects-previews 是项目缩略图,ul.cd-projects 是项目明细。另外,nav.cd-primary-nav 是一个全屏的导航菜单。

也想出现在这里?联系我们
创客主机
  1. <div class="cd-projects-container">
  2.   <ul class="cd-projects-previews">
  3.     <li>
  4.       <a href="#0">
  5.         <div class="cd-project-title">
  6.           <h2>Project 1</h2>
  7.           <p>Brief description of the project here</p>
  8.         </div>
  9.       </a>
  10.     </li>
  11.  
  12.     <li>
  13.       <!-- project preview here -->
  14.     </li>
  15.  
  16.     <!-- other project previews here -->
  17.   </ul> <!-- .cd-projects-previews -->
  18.  
  19.   <ul class="cd-projects">
  20.     <li>
  21.       <div class="preview-image">
  22.         <div class="cd-project-title">
  23.           <h2>Project 1</h2>
  24.           <p>Brief description of the project here</p>
  25.         </div> 
  26.       </div>
  27.  
  28.       <div class="cd-project-info">
  29.         <!-- project description here -->
  30.       </div> <!-- .cd-project-info -->
  31.     </li>
  32.  
  33.     <!-- projects here -->
  34.   </ul> <!-- .cd-projects -->
  35.  
  36.   <button class="scroll cd-text-replace">Scroll</button>
  37. </div> <!-- .cd-project-container -->
  38.  
  39. <nav class="cd-primary-nav" id="primary-nav">
  40.   <ul>
  41.     <li class="cd-label">Navigation</li>
  42.     <li><a href="#0">The team</a></li>
  43.     <!-- navigation items here -->
  44.   </ul>
  45. </nav> <!-- .cd-primary-nav -->

CSS 样式

在小屏幕设备中,每一个项目预览图的<li>元素的宽度等于整个视口的宽度,高度等于 1/4 视口的高度(因为 DEMO 中有 4 个子项目)。项目预览图片使用它们的子元素<a>来设置背景图片,它的高度等于整个视口的高度,并通过 translate 将它们分别移动到合适的位置上。

  1. .cd-projects-previews li {
  2.   height: 25%;
  3.   width: 100%;
  4.   overflow: hidden;
  5.   transition: transform 0.5s;
  6. }
  7. .cd-projects-previews a {
  8.   display: block;
  9.   height: 100vh;
  10.   width: 100%;
  11.   opacity: 0;
  12.   transition: opacity 0.5s;
  13.   transform: translateY(0%);
  14. }
  15. .cd-projects-previews li:nth-of-type(2) a {
  16.   transform: translateY(-25%);
  17. }
  18. .cd-projects-previews li:nth-of-type(3) a {
  19.   transform: translateY(-50%);
  20. }
  21. .cd-projects-previews li:nth-of-type(4) a {
  22.   transform: translateY(-75%);
  23. }

对于项目明细.cd-projects > li,每一个列表项都设置为绝对定位,并且宽度和高度都等于视口的宽度和高度,默认它们是隐藏的。

  1. .cd-projects > li {
  2.   position: absolute;
  3.   top: 0;
  4.   left: 0;
  5.   height: 100%;
  6.   width: 100%;
  7.   opacity: 0;
  8.   transition: opacity 0.3s;
  9. }

当用户选择了一个项目之后,相应的.cd-projects > li 会被添加.selected class,同时会为项目的预览图添加.slide-out class。

  1. .cd-projects-previews li.slide-out {
  2.   transform: translateX(-100%);
  3. }
  4.  
  5. .cd-projects > li.selected {
  6.   z-index: 1;
  7.   opacity: 1;
  8.   transition: opacity 0s;
  9. }

在大屏幕设备中(视口大于 1024 像素),项目预览图片的高度被设置为 100%视口高度,宽度等于 1/4 视口宽度,同时向左移动<a>子元素使它覆盖整个视口。

  1. @media only screen and (min-width: 1024px) {
  2.   .cd-projects-previews li {
  3.     display: inline-block;
  4.     height: 100%;
  5.     width: 25%;
  6.     float: left;
  7.   }
  8.   .cd-projects-previews li.slide-out {
  9.     transform: translateY(-100%);
  10.   }
  11.   .cd-projects-previews a {
  12.     /* width equal to window width */
  13.     width: 400%;
  14.   }
  15.   .cd-projects-previews li:nth-of-type(2) a {
  16.     transform: translateX(-25%);
  17.   }
  18.   .cd-projects-previews li:nth-of-type(3) a {
  19.     transform: translateX(-50%);
  20.   }
  21.   .cd-projects-previews li:nth-of-type(4) a {
  22.     transform: translateX(-75%);
  23.   }
  24. }

对于全屏导航菜单, .cd-primary-nav 被放置在.cd-projects-container 中,当用户点击了.cd-nav-trigger,项目预览图片会被添加.slide-out class。

  1. .cd-primary-nav {
  2.   position: absolute;
  3.   z-index: 1;
  4.   top: 0;
  5.   left: 0;
  6.   height: 100%;
  7.   width: 100%;
  8.   overflow: auto;
  9.   text-align: center;
  10.   opacity: 0;
  11.   transition: opacity 0.6s;
  12. }
  13. .cd-primary-nav.nav-visible {
  14.   opacity: 1;
  15. }

JavaScript

该 UI 设计中使用 jQuery 来检测项目预览图片的点击事件和.cd-nav-trigger 的点击事件。当用户选择了一个项目或打开了主导航菜单,slideToggleProjects()函数会处理相应的项目滑入滑出效果,而 makeUniqueRandom()函数则用于获取 1-4 之间的随机数。

  1. function slideToggleProjects(projectsPreviewWrapper, projectIndex, index, bool) {
  2.   var randomProjectIndex = makeUniqueRandom();
  3.  
  4.   if( index < numRandoms - 1 ) {
  5.     projectsPreviewWrapper.eq(randomProjectIndex).toggleClass('slide-out', bool);
  6.     setTimeout( function(){
  7.       //animate next preview project
  8.       slideToggleProjects(projectsPreviewWrapper, projectIndex, index + 1, bool);
  9.     }, 150);
  10.   } else {
  11.     //this is the last project preview to be animated 
  12.     projectsPreviewWrapper.eq(randomProjectIndex)
  13.                     .toggleClass('slide-out', bool)
  14.                     .one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
  15.       // ...
  16.       animating = false;
  17.     });
  18.   }
  19. }

简洁全屏项目列表滑动面板 UI 设计

已有 538 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(1)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!