图片/图形

超炫CSS3六边形菜单动画特效

阿里云


这是一款使用 CSS3 和少量 js 代码制作的炫酷六边形菜单动画特效。该六边形菜单在鼠标滑过时带有高光动画效果,当点击菜单后,各个菜单项沿六边形的各条边向外弹出,组成一个大的六边形。

HTML 结构

该六边形菜单使用一个<svg>来制作,菜单项使用一个无序列表来制作。

也想出现在这里?联系我们
创客主机
  1. <nav id="hexNav">
  2.   <div id="menuBtn">
  3.     <svg viewbox="0 0 100 100">
  4.       <polygon points="50 2 7 26 7 74 50 98 93 74 93 26" fill="transparent"
  5.                           stroke-width="4" stroke="#585247" stroke-dasharray="0,0,300"/>
  6.     </svg>
  7.     <span></span>
  8.   </div>
  9.   <ul id="hex">
  10.     <li class="tr"><div class="clip"><a href="#" class="content">
  11.       <img src="img/1.jpg" alt="" />
  12.       <h2 class="title">Title</h2><p>Catch phrase</p>
  13.     </a></div></li>
  14.     <li class="tr"><div class="clip"><a href="#" class="content">
  15.       <img src="img/2.jpg" alt="" />
  16.       <h2 class="title">Title</h2><p>Catch phrase</p>
  17.     </a></div></li>
  18.     <li class="tr"><div class="clip"><a href="#" class="content">
  19.       <img src="img/3.jpg" alt="" />
  20.       <h2 class="title">Title</h2><p>Catch phrase</p>
  21.     </a></div></li>
  22.     <li class="tr"><div class="clip"><a href="#" class="content">
  23.       <img src="img/4.jpg" alt="" />
  24.       <h2 class="title">Title</h2><p>Catch phrase</p>
  25.     </a></div></li>
  26.     <li class="tr"><div class="clip"><a href="#" class="content">
  27.       <img src="img/5.jpg" alt="" />
  28.       <h2 class="title">Title</h2><p>Catch phrase</p>
  29.     </a></div></li>
  30.     <li class="tr"><div class="clip"><a href="#" class="content">
  31.       <img src="img/6.jpg" alt="" />
  32.       <h2 class="title">Title</h2><p>Catch phrase</p>
  33.     </a></div></li>
  34.   </ul>
  35. </nav>

JavaScript

该六边形菜单使用少量的 js 代码来监听按钮的鼠标点击事件,为它添加和移除相应的 class 类。

  1. var hexNav = document.getElementById('hexNav');
  2.  
  3. document.getElementById('menuBtn').onclick = function() {
  4.     var className = ' ' + hexNav.className + ' ';
  5.     if ( ~className.indexOf(' active ') ) {
  6.         hexNav.className = className.replace(' active ', ' ');
  7.     } else {
  8.         hexNav.className += ' active';
  9.     }              
  10. }

超炫 CSS3 六边形菜单动画特效

已有 346 人购买
  • ov97
查看演示升级 VIP立刻购买

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

发表回复

热销模板

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

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