`

jQuery仿腾讯“今日话题”右上角的分享按钮特效

 
阅读更多
jQuery仿腾讯“今日话题”右上角的分享按钮特效
简介: jQuery仿腾讯“今日话题”右上角的分享按钮特效
经常会看腾讯网的“今日话题”,每天讨论的都是近来最热门的话题。而今天在无意中看到页面右上角的几个分享按钮效果不错;于是自己用jQuery模仿着写了一个,效果实现了,不过因为小生jQuery新手,可能代码有些繁冗,希望高手多多指教!

查看效果:demo

HTML部分:
  1. <div id="main">
  2.         <a href="#" class="item rs" title="RSS订阅"><span>RSS订阅</span><b></b></a>
  3.         <a href="#" class="item ph" title="用手机浏览"><span>用手机浏览</span><b></b></a>
  4.         <a href="#" class="item xw" title="分享到新浪微博"><span>分享到新浪微博</span><b></b></a>
  5.         <a href="#" class="item tw" title="分享到腾讯微博"><span>分享到腾讯微博</span><b></b></a>
  6.         <a href="#" class="item qz" title="分享到空间"><span>分享到空间</span><b></b></a>
  7. </div>
复制代码
JS部分:
  1. <script type='text/javascript' src='js/jquery-1.6.3.min.js'></script>
  2. <script type="text/javascript">
  3. $(document).ready(function(){
  4. $qzsp = $('a.qz span');
  5.         $twsp = $('a.tw span');
  6.         $xwsp = $('a.xw span');
  7.         $phsp = $('a.ph span');
  8.         $rssp = $('a.rs span');

  9.         $qza = $('a.qz');
  10.         $twa = $('a.tw');
  11.         $xwa = $('a.xw');
  12.         $pha = $('a.ph');
  13.         $rsa = $('a.rs');
  14.         
  15.         $('a span').hide();
  16.         //QQ空间
  17.         $qza.hover(function(){
  18.                 $(this).animate({width:"100px",paddingLeft:"10px"},300);
  19.                 $qzsp.show();
  20.         },function(){
  21.                 $(this).animate({width:"34px",paddingLeft:"0"},300);
  22.                 $qzsp.hide();
  23.         });
  24.         //腾讯微博
  25.         $twa.hover(function(){
  26.                 $(this).animate({width:"120px",paddingLeft:"10px"},300);
  27.                 $twsp.show();
  28.         },function(){
  29.                 $(this).animate({width:"34px",paddingLeft:"0"},300);
  30.                 $twsp.hide();
  31.         });
  32.         //新浪微博
  33.         $xwa.hover(function(){
  34.                 $(this).animate({width:"120px",paddingLeft:"10px"},300);
  35.                 $xwsp.show();
  36.         },function(){
  37.                 $(this).animate({width:"34px",paddingLeft:"0"},300);
  38.                 $xwsp.hide();
  39.         });
  40.         //用手机浏览
  41.         $pha.hover(function(){
  42.                 $(this).animate({width:"100px",paddingLeft:"10px"},300);
  43.                 $phsp.show();
  44.         },function(){
  45.                 $(this).animate({width:"34px",paddingLeft:"0"},300);
  46.                 $phsp.hide();
  47.         });
  48.         //RSS订阅
  49.         $rsa.hover(function(){
  50.                 $(this).animate({width:"80px",paddingLeft:"10px"},300);
  51.                 $rssp.show();
  52.         },function(){
  53.                 $(this).animate({width:"34px",paddingLeft:"0"},300);
  54.                 $rssp.hide();
  55.         });
  56. });
  57. </script>
复制代码
CSS部分:
  1. *{margin: 0;padding: 0;border: 0;}
  2. #main{width: 500px; height: 100px; border: 2px solid #b00;margin: 0 auto;background: url(images/wrapBg.png) repeat;padding: 20px;}
  3. #main a.item{width: 34px; height: 33px;display: block; float: right;margin-right: 15px;background: url(images/wbset.png) 0 0 no-repeat;text-decoration: none;color: #786123;font: 12px/33px "Microsoft Yahei",arial;position: relative;}
  4. #main a.item span:hover{text-decoration: underline;}
  5. #main a b{width: 34px; height: 33px;display: block;background: url(images/wbIconBg2.png) no-repeat;position: absolute;right: 0;}
  6. #main a span{float: left;}

  7. #main a.qz b{background-position:-1px 0;}
  8. #main a.tw b{background-position:-43px 0;}
  9. #main a.xw b{background-position:-85px 0;}
  10. #main a.ph b{background-position:-175px 0;}
  11. #main a.rs b{background-position:-128px 0;}
复制代码


仿腾讯今日话题右上角的分享按钮特效.rar

43.99 KB, 下载次数: 168

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics