基于jQuery实现的仿百度首页滑动选项卡效果代码
2015-11-16 15:26
976 查看
本文实例讲述了基于jQuery实现的仿百度首页滑动选项卡效果代码。分享给大家供大家参考,具体如下:
今天给大家分享一款基于jQuery的仿百度首页滑动选项卡,可实现tab选项卡内容上下翻滚切换的功能。这款选项卡适用浏览器有:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗。效果图如下:
在线演示地址如下:
http://demo.jb51.net/js/2015/jquery-f-baidu-hd-nav-style-codes/
完整实例代码代码点击此处本站下载。
html代码:
<div class="main-page"> <div class="left"> <div class="nav-back"> </div> <div class="nav"> <div class="on"> 导航</div> <div> 新闻</div> <div> 世界杯</div> <div> 音乐</div> <div> 彩票</div> </div> </div> <div class="right"> <div class="content-back"> </div> <div class="content"> <div> 站长素材1</div> <div> 站长素材2</div> <div> 站长素材3</div> <div> 站长素材4</div> <div> 站长素材5</div> </div> </div> <div class="clear"> </div> </div>
css代码:
body { background: url(images/65.jpg) no-repeat fixed center center; } .clear { clear: both; } .main-page { margin: 200px auto 0 auto; width: 700px; height: 300px; } .main-page .left, .main-page .right { float: left; } .main-page .nav-back { width: 60px; height: 300px; background: #000; opacity: .3; filter: alpha(opacity=30); } .main-page .nav { position: relative; margin-top: -300px; width: 60px; text-align: center; font-size: 14px; font-family: "微软雅黑"; color: #fff; } .main-page .nav div { height: 32px; line-height: 28px; } .main-page .nav div.on { background: #0094ea; } .main-page .right { width: 620px; height: 300px; margin-left: 20px; } .main-page .content-back { width: 620px; height: 300px; background: #fff; opacity: .3; } .main-page .content { position: relative; width: 600px; height: 280px; margin-top: -300px; padding: 10px; overflow: hidden; } .main-page .content div { width: 600px; height: 280px; margin-bottom: 10px; background: #fff; }
js代码:
$(".main-page .nav div").mouseenter(function () { var $this = $(this); var index = $this.index(); }).mouseleave(function () { var $this = $(this); var index = $this.index(); }).click(function () { var $this = $(this); var index = $this.index(); var l = -(index * 290); $(".main-page .nav div").removeClass("on"); $(".main-page .nav div").eq(index).addClass("on"); $(".main-page .content div:eq(0)").stop().animate({ "margin-top": l }, 500); });
希望本文所述对大家jQuery程序设计有所帮助。
您可能感兴趣的文章:
- jQuery实现的经典滑动门效果
- jQuery实现自动切换播放的经典滑动门效果
- jquery仅用6行代码实现滑动门效果
- jquery实现标题字体变换的滑动门菜单效果
- jQuery实现类似滑动门切换效果的层切换
- 基于jquery自己写tab滑动门(通用版)
- EasySlider 基于jQuery功能强大简单易用的滑动门插件
- jQuery实现TAB选项卡切换特效简单演示
- jquery实现具有嵌套功能的选项卡
- jquery实现经典的淡入淡出选项卡效果代码
- jQuery实现仿腾讯迷你首页选项卡效果代码
- jQuery实现的Tab滑动选项卡及图片切换(多种效果)小结
- jQuery实现的多滑动门,多选项卡效果代码
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- JavaScript演示排序算法
- 2015-2016网页设计趋势分析 Web Design of Trends
- jQuery Ajax 跨域调用
- 移动端的长按事件
- jquery教程靠边站,一分钱不花让你免费学会jquery
- JQuery+Strusts1.x无刷新登录
- JavaScript 各种遍历方式详解
- jQuery菜单插件用法实例
- JQuery 初体验(建议学习jquery)
- Jquery实现的table最后一行添加样式的代码
- jQuery实现向下滑出的平滑下拉菜单效果
- jQuery 练习[一] 学习jquery的准备工作
- jquery获得页面元素的坐标值实现思路及代码
- 使用Browserify配合jQuery进行编程的超级指南
- jquery如何实现在加载完iframe的内容后再进行操作
- jquery $.ajax()取xml数据的小问题解决方法
- jQuery '行 4954 错误: 不支持该属性或方法' 的问题解决方法
- Jquery 表单取值赋值的一些基本操作
- jQuery实现复选框批量选择与反选的方法