公告:“业余草”微信公众号提供免费CSDN下载服务(只下Java资源),关注业余草微信公众号,添加作者微信:xttblog2,发送下载链接帮助你免费下载!
本博客日IP超过2000,PV 3000 左右,急需赞助商。
极客时间所有课程通过我的二维码购买后返现24元微信红包,请加博主新的微信号:xttblog2,之前的微信号好友位已满,备注:返现
受密码保护的文章请关注“业余草”公众号,回复关键字“0”获得密码
所有面试题(java、前端、数据库、springboot等)一网打尽,请关注文末小程序
腾讯云】1核2G5M轻量应用服务器50元首年,高性价比,助您轻松上云
本博客日IP超过2000,PV 3000 左右,急需赞助商。
极客时间所有课程通过我的二维码购买后返现24元微信红包,请加博主新的微信号:xttblog2,之前的微信号好友位已满,备注:返现
受密码保护的文章请关注“业余草”公众号,回复关键字“0”获得密码
所有面试题(java、前端、数据库、springboot等)一网打尽,请关注文末小程序

腾讯云】1核2G5M轻量应用服务器50元首年,高性价比,助您轻松上云
今天闲来无事就使用 jQuery 制作了一款导航产品,给大家分享一下。
jQuery蜂巢状布局导航标签代码是一款六边形蜂窝效果的CSS布局,适合做导航或者关键词展示使用。也可以做网站上的标签云。
效果图
实现原理
主要使用 transform 图片旋转。具体可以参考我的这篇文章:http://www.xttblog.com/?p=498
实现代码
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>业余草:www.xttblog.com 蜂巢tab切换实例</title> <meta http-equiv="keywords" content=""> <meta http-equiv="description" content=""> <meta http-equiv="X-UA-Compatible" content=”IE=Edge,chrome=1″ /> <meta name="renderer" content="webkit"> <style type="text/css"> .Ct{ width:1000px; margin:0 auto; } .ywPart1{ width: 310px; margin: 0 auto; padding: 20px 10px 20px 30px; } /**业余草:蜂巢样式***/ .hex { float: left; margin-left: 2px; margin-bottom: -18px; cursor: pointer; } .hex .hex_top { width: 0; border-bottom: 20px solid #f0ce8b; border-left: 35px solid transparent; border-right: 35px solid transparent; margin-top: -1px\9\0; margin-top: 0px\0; } .hex .hex_middle { width: 70px; height: 30px; line-height: 30px; background: #f0ce8b; text-align: center; font-family: "宋体"; color: #333333; } .hex .hex_bottom { width: 0; border-top: 20px solid #f0ce8b; border-left: 35px solid transparent; border-right: 35px solid transparent; margin-top: -1px\9\0; margin-top: 0px\0; } .hex-row { clear: left; } .hex-row.even { margin-left: 38px; } .hex-row.odd { margin-right: 38px; } .hex.hexActive .hex_top { width: 0; border-bottom: 20px solid #86ccac; border-left: 35px solid transparent; border-right: 35px solid transparent; margin-top: -1px\9\0; margin-top: 0px\0; } .hex.hexActive .hex_middle { width: 70px; height: 30px; line-height: 30px; background: #86ccac; text-align: center; font-family: "宋体"; color: #FFFFFF; } .hex.hexActive .hex_bottom { width: 0; border-top: 20px solid #86ccac; border-left: 35px solid transparent; border-right: 35px solid transparent; margin-top: -1px\9\0; margin-top: 0px\0; } /**蜂巢样式***/ </style> </head> <body> <div class="Ct"> <div class="ywPart1" id="hexDiv"> <!-- 描述:蜂巢 --> <div class="hex hexActive" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">首页</div> <div class="hex_bottom"></div> </div> <div class="hex" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">业余草</div> <div class="hex_bottom"></div> </div> <div class="hex" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">java</div> <div class="hex_bottom"></div> </div> <div class="hex" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">html5</div> <div class="hex_bottom"></div> </div> <div class="hex hex-row even" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">c++</div> <div class="hex_bottom"></div> </div> <div class="hex" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">数据库</div> <div class="hex_bottom"></div> </div> <div class="hex" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">敏捷管理</div> <div class="hex_bottom"></div> </div> <div class="hex hex-row" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">业余杂谈</div> <div class="hex_bottom"></div> </div> <div class="hex" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">css3</div> <div class="hex_bottom"></div> </div> <div class="hex" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">js</div> <div class="hex_bottom"></div> </div> <div class="hex" name="hexBlcok"> <div class="hex_top"></div> <div class="hex_middle">其他</div> <div class="hex_bottom"></div> </div> <div class="ClearFloat"></div> </div> </div> <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> <script> $("#hexDiv").find("div[name='hexBlcok']").on("click",function(){ $(this).addClass("hexActive"); $(this).siblings("div[name='hexBlcok']").removeClass("hexActive"); }); </script> </body> </html>
最后,欢迎关注我的个人微信公众号:业余草(yyucao)!可加作者微信号:xttblog2。备注:“1”,添加博主微信拉你进微信群。备注错误不会同意好友申请。再次感谢您的关注!后续有精彩内容会第一时间发给您!原创文章投稿请发送至532009913@qq.com邮箱。商务合作也可添加作者微信进行联系!
本文原文出处:业余草: » jQuery 实现蜂窝导航菜单