本文实例为大家分享了jquery仿京东侧边栏导航的具体代码,供大家参考,具体内容如下
样式代码
<style> *{ padding: 0; margin: 0; border: 0; } body{ height: 2000px; } .right_ng{ width: 40px; height: 100%; position: absolute; position: fixed; right: 0px; background: #666666; } .sign{ width: 40px; height: 40px; margin-top:280%; } .sign_top{ margin-top: 10px; } .sign_add_height{ height: 140px; background: #888888; color: #ffffff; font-size: 13px; list-style: none; font-weight: bold; } .sign_add_height ul{ margin-top: 6px; cursor: pointer; } .sign_add_height ul li{ list-style-type: none; width: 20px; height: 20px; margin-top: 5px; } .buy{ width: 20px; height: 20px; border-radius: 10px 10px; background:#666; } .sign_QR{ margin-top: 200%; position: absolute; bottom: 50px; position: fixed; background: #666666; } .sign_end{ position: absolute; bottom: 0px; position: fixed; background: #666666; } .sign img{ width: 22px; height: 22px; margin-top: 10px; cursor: pointer; } .run_sign{ width: 100px; height: 40px; margin-left: -100px; margin-top: -35px; background: #666666; color: #1afa29; font-size: 13px; line-height: 40px; cursor: pointer; } .run_QR{ height: 250px; width: 200px; margin-left: -200px; margin-top: -245px; } .sign_float{ position: fixed; } </style>
jQuery代码
这里把图片的名称换成数字的,每一个图标都有两个图片, 一个白色和一个绿色的,当鼠标移动到其中一个图标处时,改变其图片使其变色,因为一共有八个图标,所以总共有16张图片。因此图片名改变为当前图片名称数字+8。
这里用的动态是slideDown与slideUp。需要注意的是要设置索引来寻找但前对象的位置(因为是在for循环里有了索引才能找到当前对象的图片的数字名称)。
<script> $(function(){ $('.run_sign').css('display','none'); $(".run_QR img").attr("src","img/17.png"); for(var i=0;i<8;i++){ if(i==6){ $('.sign').eq(i).hover(function(){ $(this).css('background','#ea68a2').find('.img_1').attr("src","img/15.png"); $(this).find('.run_sign').css('visibility','visible').stop().slideDown(200);},function(){ $(this).css('background','#666666').find('.img_1').attr("src","img/7.png"); $(this).find('.run_sign').css('visibility','visible').stop().slideUp(200);})} else if(i==5){ $('.sign').eq(i).hover(function(){ $(this).css('background','#ea68a2').find('img').attr("src","img/14.png");},function(){ $(this).css('background','#888888').find('img').attr("src","img/6.png");})} else{ $('.sign').eq(i).hover(function(){ var b=$(this).index(); $(this).css('background','#ea68a2').find('img').attr("src","img/"+(b+9)+".png"); $(this).find('.run_sign').css('visibility','visible').stop().slideDown(200);},function(){ var b=$(this).index(); $(this).css('background','#666666').find('img').attr("src","img/"+(b+1)+".png"); $(this).find('.run_sign').css('visibility','visible').stop().slideUp(200);})}} }); </script>
布局代码
风云阁资源网 Design By www.bgabc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
风云阁资源网 Design By www.bgabc.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 战锤40K星际战士2狙击职业介绍|狙击职业技能效果一览
- RobertSaxtonTheResurrectionoftheSoldiers(2024)[24Bit-192kHz]FLAC
- 唐成杨东哥弹唱《情若真HQ》头版限量编号[WAV+CUE]
- 柏菲·HIFI风情1《一杯香茶》限量开盘母带ORMCD[WAV+CUE]
- 发糖了!《黑神话》动画导演绘制八戒紫蛛儿中秋贺图
- “时光系列”新作《时光3:永耀之境》首曝:画风更真实的恋爱模拟RPG
- 《战地》游戏主管:始终认为《战地》未来销量能超越《使命召唤》
- 《伤感民谣 值得收藏的音乐极品 2CD》[WAV/分轨][1.2GB]
- 《邓紫棋 巨肺唱将小天后有心人 2CD》[WAV/分轨][1.2GB]
- 《迪克牛仔 坛奇精选 2CD台首版》 [WAV+CUE][600MB]
- 陈明.1998-为了爱影视歌曲+新歌【中唱】【WAV+CUE】
- 黄小琥.2009-简单/不简单【华纳】【WAV+CUE】
- 洪卓立.2010-TASTE.OF.LOVE新曲+精丫英皇娱乐】【WAV+CUE】
- 战锤40K星际战士2职业强度排行
- 交错战线PVE国家队成员以及常用角色推荐