jquery仅用6行代码实现滑动门效果
2015-09-07 15:51
696 查看
本文实例讲述了jquery仅用6行代码实现滑动门效果。分享给大家供大家参考。具体如下:
这是一个基于jQuery的滑动门导航栏,仅6行代码,不知还有没有比此更少的代码了,在滑动门的实现过程中,用背景图片修饰了每个“门”的背景,更美观漂亮,有着极好的用户操作体验。
运行效果如下图所示:
在线演示地址如下:
http://demo.jb51.net/js/2015/jquery-simple-nav-menu-style-codes/
具体代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jquery 6行代码实现滑动门</title> <style> *{margin:0; padding:0;font-family:"宋体",Arial, Helvetica, sans-serif; font-size:12px} .ts{ width:50%; margin:0 auto} .ts .tsHead{clear:both; height:27px;background:url(images/titLine.gif) repeat-x left bottom; border-left:1px solid #88AAD6; border-right:1px solid #88AAD6; border-top:1px solid #88AAD6} .ts .titLeft{float:left; height:27px;font-size:1px; width:12px;;background:url(images/titLeft.gif) no-repeat} .ts .titOp{float:left; height:21px; padding:5px 0 0} .ts .titOp li{ float:left; width:100px;height:15px; padding:5px 0 0; margin:0 0 0 3px;border:1px solid #88AAD6; border-bottom:1px solid #fff;background:#eeeeff; color:#999;text-align:center; cursor:default} .ts .titOp li.current{ background:#fff;color:#290052; } .ts .titRight{float:right; height:26px;font-size:1px; width:32px;;background:url(images/titRight.gif) no-repeat} .ts .line{border-left:1px solid #88AAD6;border-right:1px solid #88AAD6;clear:both; height:13px; line-height:13px; padding:5px; background:#E9F9FE} .ts .tsMb{border:1px solid #88AAD6; border-top:none; padding:10px; height:120px; min-height:100px; font-weight:bold} </style> <script type="text/javascript" src="jquery-1.6.2.min.js"></script> <script> $(function(){ $("#tsMb div:not(:first)").hide(); $("#titOp li").each(function(index){ $(this).mouseover( function(){ $("#titOp li.current").removeClass("current"); $(this).addClass("current"); $("#tsMb > div:visible").hide(); $("#tsMb div:eq(" + index + ")").show(); }) }) }) </script> </head> <body> <div style="clear:both; height:30px"></div> <!--调试层--> <div class="ts"> <div class="tsHead"> <div class="titLeft"></div> <div class="titOp" id="titOp"> <ul> <li class="current">脚本调试器</li> <li>样式调试器</li> <li>DOM调试器</li> </ul> </div> <div class="titRight"></div> </div> <div class="line">sadfasdfsd</div> <div class="tsMb" id="tsMb"> <div>脚本</div> <div>样式</div> <div>DOM</div> </div> </div> <!--调试层 end--> </body> </html>
希望本文所述对大家的jquery程序设计有所帮助。
您可能感兴趣的文章:
- jQuery实现的经典滑动门效果
- jQuery实现自动切换播放的经典滑动门效果
- jquery实现标题字体变换的滑动门菜单效果
- jQuery实现类似滑动门切换效果的层切换
- 基于jquery自己写tab滑动门(通用版)
- EasySlider 基于jQuery功能强大简单易用的滑动门插件
- jQuery实现TAB选项卡切换特效简单演示
- jquery实现具有嵌套功能的选项卡
- 基于jQuery实现的仿百度首页滑动选项卡效果代码
- jquery实现经典的淡入淡出选项卡效果代码
- jQuery实现仿腾讯迷你首页选项卡效果代码
- jQuery实现的Tab滑动选项卡及图片切换(多种效果)小结
- jQuery实现的多滑动门,多选项卡效果代码
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- JavaScript演示排序算法
- 2015-2016网页设计趋势分析 Web Design of Trends
- jQuery Ajax 跨域调用
- 移动端的长按事件
- jquery教程靠边站,一分钱不花让你免费学会jquery
- JQuery+Strusts1.x无刷新登录
- jQuery菜单插件用法实例
- JQuery 初体验(建议学习jquery)
- Jquery实现的table最后一行添加样式的代码
- jQuery实现向下滑出的平滑下拉菜单效果
- jQuery 练习[一] 学习jquery的准备工作
- jquery获得页面元素的坐标值实现思路及代码
- 使用Browserify配合jQuery进行编程的超级指南
- jquery如何实现在加载完iframe的内容后再进行操作
- jquery $.ajax()取xml数据的小问题解决方法
- jQuery '行 4954 错误: 不支持该属性或方法' 的问题解决方法
- Jquery 表单取值赋值的一些基本操作
- jQuery实现复选框批量选择与反选的方法
- jQuery中的常用事件总结