导航菜单

炫酷CSS3过渡动画全屏导航菜单UI设计

阿里云


这是一款效果非常炫酷的带炫酷 CSS3 过渡动画的全屏导航菜单网页 UI 设计效果。该导航菜单使用 CSS3 和少量的 jQuery 来制作,当用户点击左上角的汉堡包按钮时,全屏菜单将从屏幕上方滑动显示出来。

HTML 结构

该全屏导航菜单的汉堡包按钮使用一个

也想出现在这里?联系我们
创客主机
元素来包裹一个按钮元素,按钮中使用一组元素来作为汉堡包按钮的三根线条。

  1. <div class="nav">
  2.   <button class="btn-nav">
  3.     <span class="icon-bar top"></span>
  4.     <span class="icon-bar middle"></span>
  5.     <span class="icon-bar bottom"></span>
  6.   </button>
  7. </div>

导航菜单使用一个

来包裹一个无序列表。默认状态下它是隐藏的。

  1. <div class="nav-content hideNav hidden">
  2.   <ul class="nav-list">
  3.     <li class="nav-item"><a href="#" class="item-anchor">item 1</a></li>
  4.     <li class="nav-item"><a href="#" class="item-anchor">item 2</a></li>
  5.     <li class="nav-item"><a href="#" class="item-anchor">item 3</a></li>
  6.     <li class="nav-item"><a href="#" class="item-anchor">item 4</a></li>
  7.   </ul>
  8. </div>

CSS 样式

汉堡包按钮的基本 CSS 样式如下:当汉堡包按钮被鼠标点击或在移动触摸设备上被触摸的时候,它会被添加一个 animated class,这个 class 类用来制作汉堡包按钮的颜色变化动画和变形动画。

  1. .btn-nav {
  2.   position: fixed;
  3.   top: 50px;
  4.   left: 30px;
  5.   background: transparent;
  6.   border: none;
  7.   padding: 10px;
  8.   -webkit-transition: all .5s ease;
  9.   -moz-transition: all .5s ease;
  10.   -ms-transition: all .5s ease;
  11.   -o-transition: all .5s ease;
  12.   transition: all .5s ease;
  13.   cursor: pointer;
  14.   z-index: 99999;
  15. }
  16.  
  17. .btn-nav:focus {
  18.   outline: 0;
  19. }
  20.  
  21. .icon-bar {
  22.   display: block;
  23.   margin: 6px 0;
  24.   width: 40px;
  25.   height: 5px;
  26.   background-color: #FFFFFF;
  27. }
  28.  
  29. .btn-nav:hover .icon-bar {
  30.   -webkit-transition: all 1s ease;
  31.   -moz-transition: all 1s ease;
  32.   -ms-transition: all 1s ease;
  33.   -o-transition: all 1s ease;
  34.   transition: all 1s ease;
  35.   background-color: #FCA311;
  36. }
  37.  
  38. .animated {
  39.   display: block;
  40.   margin: 0 auto;
  41. }
  42.  
  43. .animated:hover .icon-bar,
  44. .animated:focus .icon-bar{
  45.   background-color: #FCA311;
  46. }
  47.  
  48. .animated:focus {
  49.   cursor: pointer;
  50.   z-index: 9999;
  51. }
  52.  
  53. .middle {
  54.   margin: 0 auto;
  55. }
  56.  
  57. .icon-bar {
  58.   -webkit-transition: all .7s ease;
  59.   -moz-transition: all .7s ease;
  60.   -ms-transition: all .7s ease;
  61.   -o-transition: all .7s ease;
  62.   transition: all .7s ease;
  63.   z-index: 999999;
  64. }
  65.  
  66. .animated .icon-bar {
  67.   z-index: 999999;
  68.   background-color: #FCA311;
  69. }
  70.  
  71. .animated .top {
  72.   -webkit-transform: translateY(10px) rotateZ(45deg);
  73.   -moz-transform: translateY(10px) rotateZ(45deg);
  74.   -ms-transform: translateY(10px) rotateZ(45deg);
  75.   -o-transform: translateY(10px) rotateZ(45deg);
  76.   transform: translateY(10px) rotateZ(45deg);
  77. }
  78.  
  79. .animated .bottom {
  80.   -webkit-transform: translateY(-11px) rotateZ(-45deg);
  81.   -moz-transform: translateY(-11px) rotateZ(-45deg);
  82.   -ms-transform: translateY(-11px) rotateZ(-45deg);
  83.   -o-transform: translateY(-11px) rotateZ(-45deg);
  84.   transform: translateY(-11px) rotateZ(-45deg);
  85. }
  86.  
  87. .animated .middle {
  88.   width: 0;
  89. }

全屏导航菜单的 CSS 样式也非常简单:默认情况下它使用 hidden 和 hidden class 类来隐藏,在用户用鼠标点击或在移动触摸设备中触摸了汉堡包按钮时,将移除这两个 class 类,替换为 showNav class。

  1. .nav {
  2.   position: relative;
  3.   width: auto;
  4.   display: inline-block;
  5.   border: none;
  6. }
  7.  
  8. .nav-content {
  9.   position: fixed;
  10.   top: -100%;
  11.   bottom: 0;
  12.   left: 0;
  13.   right: 0;
  14.   background: #000000;
  15.   display: block;
  16.   height: 100%;
  17.   z-index: 9;
  18. }
  19.  
  20. .nav-list {
  21.   list-style: none;
  22.   padding: 0;
  23.   position: relative;
  24.   top: 30%;
  25. }
  26.  
  27. .item-anchor:after {
  28.   content: "";
  29.   position: absolute;
  30.   width: 3px;
  31.   height: 3px;
  32.   left: 0;
  33.   bottom: 0;
  34.   z-index: 9;
  35.   background: transparent;
  36.   -webkit-transition: all 1s ease;
  37.   -moz-transition: all 1s ease;
  38.   -ms-transition: all 1s ease;
  39.   -o-transition: all 1s ease;
  40.   transition: all 1s ease;
  41. }
  42.  
  43. .item-anchor {
  44.   color: #fff;
  45.   font-size: 30px;
  46.   text-transform: uppercase;
  47.   position: relative;
  48.   text-decoration: none;
  49.   padding: 10px;
  50. }
  51.  
  52. .item-anchor:hover,
  53. .item-anchor:focus {
  54.   color: #FCA311;
  55.   -webkit-transition: all 1s ease;
  56.   -moz-transition: all 1s ease;
  57.   -ms-transition: all 1s ease;
  58.   -o-transition: all 1s ease;
  59.   transition: all 1s ease;
  60. }
  61.  
  62. .item-anchor:hover:after,
  63. .item-anchor:focus:after{
  64.   width: 100%;
  65.   background: #FCA311;
  66.   -webkit-transition: all 1s ease;
  67.   -moz-transition: all 1s ease;
  68.   -ms-transition: all 1s ease;
  69.   -o-transition: all 1s ease;
  70.   transition: all 1s ease;
  71. }
  72.  
  73. .nav-item {
  74.   margin: 40px auto;
  75.   text-align: center;
  76. }
  77.  
  78. .hideNav {
  79.   -webkit-animation: hideNav 1s ease forwards;
  80.   -moz-animation: hideNav 1s ease forwards;
  81.   -o-animation: hideNav 1s ease forwards;
  82.   animation: hideNav 1s ease forwards;
  83. }
  84.  
  85. .hidden {
  86.   display: none;
  87. }

JavaScript

该全屏菜单使用 jQuery 来处理汉堡包按钮被鼠标点击或移动触摸时的事件。

  1. $(window).load(function () {
  2.   $('.btn-nav').on('click tap', function () {
  3.       $('.nav-content').toggleClass('showNav hideNav').removeClass('hidden');
  4.       $(this).toggleClass('animated');
  5.   });
  6. });

炫酷 CSS3 过渡动画全屏导航菜单 UI 设计

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

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

发表回复

热销模板

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

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