超酷炫 CSS3垂直手风琴菜单

秋天来啦!秋天来啦!田野里就是美丽的图画。花生躲在地下,包着红色的毛毯,住在土黄色的房间里睡大觉。玉米姐姐穿着绿色的裙子,在叶子上跳舞,南瓜爷爷鼓着金黄色的大肚子,坐着高级的南瓜车,一边看风景一边享受。西红柿露出火红火红的脸蛋,正对着我们微笑。谁使秋天这样美?看,田野里的菊花做出了回答,菊花顶着一个爆炸头,在微风中轻轻摇动,好像在说:是勤劳的人们画出了秋天的图画。

CSS3目前非常流行,在很多开发者看来,CSS3是制作网页动画和网页特效的神器,很多意想不到的效果都可以用CSS3实现。但是今天我们要分享一款用CSS3实现的非常普通的菜单,它是一个垂直的手风琴折叠菜单,先来看看效果图:

实现代码如下:

XML/HTML Code复制内容到剪贴板
  1. <ulid="accordion"class="accordion">
  2. <li>
  3. <divclass="link"><iclass="fafa-paint-brush"></i>Diseñoweb<iclass="fafa-chevron-down"></i></div>
  4. <ulclass="submenu">
  5. <li><arel="nofollow noopener noreferrer" href="#">Photoshop</a></li>
  6. <li><arel="nofollow noopener noreferrer" href="#">HTML</a></li>
  7. <li><arel="nofollow noopener noreferrer" href="#">CSS</a></li>
  8. <li><arel="nofollow noopener noreferrer" href="#">Maquetacionweb</a></li>
  9. </ul>
  10. </li>
  11. <li>
  12. <divclass="link"><iclass="fafa-code"></i>Desarrollofront-end<iclass="fafa-chevron-down"></i></div>
  13. <ulclass="submenu">
  14. <li><arel="nofollow noopener noreferrer" href="#">Javascript</a></li>
  15. <li><arel="nofollow noopener noreferrer" href="#">jQuery</a></li>
  16. <li><arel="nofollow noopener noreferrer" href="#">Frameworksjavascript</a></li>
  17. </ul>
  18. </li>
  19. <li>
  20. <divclass="link"><iclass="fafa-mobile"></i>Diseñoresponsive<iclass="fafa-chevron-down"></i></div>
  21. <ulclass="submenu">
  22. <li><arel="nofollow noopener noreferrer" href="#">Tablets</a></li>
  23. <li><arel="nofollow noopener noreferrer" href="#">Dispositivosmobiles</a></li>
  24. <li><arel="nofollow noopener noreferrer" href="#">Mediosdeescritorio</a></li>
  25. <li><arel="nofollow noopener noreferrer" href="#">Otrosdispositivos</a></li>
  26. </ul>
  27. </li>
  28. <li><divclass="link"><iclass="fafa-globe"></i>Posicionamientoweb<iclass="fafa-chevron-down"></i></div>
  29. <ulclass="submenu">
  30. <li><arel="nofollow noopener noreferrer" href="#">Google</a></li>
  31. <li><arel="nofollow noopener noreferrer" href="#">Bing</a></li>
  32. <li><arel="nofollow noopener noreferrer" href="#">Yahoo</a></li>
  33. <li><arel="nofollow noopener noreferrer" href="#">Otrosbuscadores</a></li>
  34. </ul>
  35. </li>
  36. </ul>

CSS代码:

CSS Code复制内容到剪贴板
  1. .accordion{
  2. width:100%;
  3. max-width:360px;
  4. margin:30pxauto20px;
  5. background:#FFF;
  6. -webkit-border-radius:4px;
  7. -moz-border-radius:4px;
  8. border-radius:4px;
  9. }
  10. .accordion.link{
  11. cursor:pointer;
  12. display:block;
  13. padding:15px15px15px42px;
  14. color:#4D4D4D;
  15. font-size:14px;
  16. font-weight:700;
  17. border-bottom:1pxsolid#CCC;
  18. position:relative;
  19. -webkit-transition:all0.4sease;
  20. -o-transition:all0.4sease;
  21. transition:all0.4sease;
  22. }
  23. .accordionli:last-child.link{
  24. border-bottom:0;
  25. }
  26. .accordionlii{
  27. position:absolute;
  28. top:16px;
  29. left:12px;
  30. font-size:18px;
  31. color:#595959;
  32. -webkit-transition:all0.4sease;
  33. -o-transition:all0.4sease;
  34. transition:all0.4sease;
  35. }
  36. .accordionlii.fa-chevron-down{
  37. rightright:12px;
  38. left:auto;
  39. font-size:16px;
  40. }
  41. .accordionli.open.link{
  42. color:#b63b4d;
  43. }
  44. .accordionli.openi{
  45. color:#b63b4d;
  46. }
  47. .accordionli.openi.fa-chevron-down{
  48. -webkit-transform:rotate(180deg);
  49. -ms-transform:rotate(180deg);
  50. -o-transform:rotate(180deg);
  51. transform:rotate(180deg);
  52. }
  53. /**
  54. *Submenu
  55. -----------------------------*/
  56. .submenu{
  57. display:none;
  58. background:#444359;
  59. font-size:14px;
  60. }
  61. .submenuli{
  62. border-bottom:1pxsolid#4b4a5e;
  63. }
  64. .submenua{
  65. display:block;
  66. text-decoration:none;
  67. color:#d9d9d9;
  68. padding:12px;
  69. padding-left:42px;
  70. -webkit-transition:all0.25sease;
  71. -o-transition:all0.25sease;
  72. transition:all0.25sease;
  73. }
  74. .submenua:hover{
  75. background:#b63b4d;
  76. color:#FFF;
  77. }

jQuery代码:

JavaScript Code复制内容到剪贴板
  1. $(function(){
  2. varAccordion=function(el,multiple){
  3. this.el=el||{};
  4. this.multiple=multiple||false;
  5. //Variablesprivadas
  6. varlinks=this.el.find('.link');
  7. //Evento
  8. links.on('click',{el:this.el,multiple:this.multiple},this.dropdown)
  9. }
  10. Accordion.prototype.dropdown=function(e){
  11. var$el=e.data.el;
  12. $this=$(this),
  13. $next=$this.next();
  14. $next.slideToggle();
  15. $this.parent().toggleClass('open');
  16. if(!e.data.multiple){
  17. $el.find('.submenu').not($next).slideUp().parent().removeClass('open');
  18. };
  19. }
  20. varaccordion=newAccordion($('#accordion'),false);
  21. });

本文链接:http://www.codeceo.com/article/css3-vertical-accordion-menu.html
本文作者:码农网 – 小峰

以上就是超酷炫 CSS3垂直手风琴菜单。考研不简单,实现自己的梦想也不容易,但是!不代表不可能,坚持,忍耐,拼搏,进入清华没有问题!更多关于超酷炫 CSS3垂直手风琴菜单请关注haodaima.com其它相关文章!

标签: 酷炫