Tab选项卡

Material Design风格滑动选项卡特效

阿里云

这是一款效果非常炫酷的谷歌 Material Design 风格 jQuery 和 CSS3 滑动选项卡特效。该选项卡特效集合了扁平风格设计和按钮点击波特效。是一款设计的非常不错的 Material Design 风格作品。

使用方法:

TAB 选项卡使用一个无序列表来制作。

也想出现在这里?联系我们
创客主机
  1. <ul>
  2.   <li>Tab One</li>
  3.   <li>Tab Two</li>
  4.   <li>Tab Three</li>
  5.   <li class="slider"></li>
  6. </ul>

CSS 样式:

TAB 选项卡的基本样式如下:

  1. ul {
  2.   font-size: 0;
  3.   position: relative;
  4.   padding: 0;
  5.   width: 480px;
  6.   margin: 40px auto;
  7.   user-select: none;
  8. }
  9.  
  10. li {
  11.   display: inline-block;
  12.   width: 160px;
  13.   height: 60px;
  14.   background: #E95546;
  15.   font-size: 16px;
  16.   text-align: center;
  17.   line-height: 60px;
  18.   color: #fff;
  19.   text-transform: uppercase;
  20.   position: relative;
  21.   overflow: hidden;
  22.   cursor: pointer;
  23. }

下面是每一个选项卡按钮下面的滑动线条的样式:

  1. .slider {
  2.   display: block;
  3.   position: absolute;
  4.   bottom: 0;
  5.   left: 0;
  6.   height: 4px;
  7.   background: #4FC2E5;
  8.   transition: all 0.5s;
  9. }

接下来使用 CSS3 animations 来创建按钮点击波效果。

  1. .ripple {
  2.   width: 0;
  3.   height: 0;
  4.   border-radius: 50%;
  5.   background: rgba(255, 255, 255, 0.4);
  6.   -webkit-transform: scale(0);
  7.   -ms-transform: scale(0);
  8.   transform: scale(0);
  9.   position: absolute;
  10.   opacity: 1;
  11. }
  12.  
  13. .rippleEffect {
  14.   -webkit-animation: rippleDrop .6s linear;
  15.   animation: rippleDrop .6s linear;
  16. }
  17.  
  18. @-webkit-keyframes 
  19.   rippleDrop {  100% {
  20.    -webkit-transform: scale(2);
  21.    transform: scale(2);
  22.    opacity: 0;
  23.   }
  24. }
  25.  
  26. @keyframes 
  27.   rippleDrop {  100% {
  28.    -webkit-transform: scale(2);
  29.    transform: scale(2);
  30.    opacity: 0;
  31.   }
  32. }

JAVASCRIPT 部分:

整个 Material Design 风格的选项卡特效的互动使用下面的 jQuery 代码:

  1. $("ul li").click(function(e) {
  2.  
  3.   if ($(this).hasClass('slider')) {
  4.     return;
  5.   }
  6.  
  7.   var whatTab = $(this).index();
  8.  
  9.   var howFar = 160 * whatTab;
  10.  
  11.   $(".slider").css({
  12.     left: howFar + "px"
  13.   });
  14.  
  15.   $(".ripple").remove();
  16.  
  17.   var posX = $(this).offset().left,
  18.       posY = $(this).offset().top,
  19.       buttonWidth = $(this).width(),
  20.       buttonHeight = $(this).height();
  21.  
  22.   $(this).prepend("<span class='ripple'></span>");
  23.  
  24.   if (buttonWidth >= buttonHeight) {
  25.     buttonHeight = buttonWidth;
  26.   } else {
  27.     buttonWidth = buttonHeight;
  28.   }
  29.  
  30.   var x = e.pageX - posX - buttonWidth / 2;
  31.   var y = e.pageY - posY - buttonHeight / 2;
  32.  
  33.   $(".ripple").css({
  34.     width: buttonWidth,
  35.     height: buttonHeight,
  36.     top: y + 'px',
  37.     left: x + 'px'
  38.   }).addClass("rippleEffect");
  39.  
  40. });

Material Design 风格滑动选项卡特效

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

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

发表回复

热销模板

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

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