拷贝出腾讯微博关于奥运会的拉绳开关特效

开发 前端
我在国外的网站里还是发现了一个我感兴趣的特效,就是腾讯微博里的"拉绳开关"的换肤效果,这个比较简单,我把代码“抠 ”了出来。

奥运会正在进行中,各大网站都因为这盛会有所改版或者是拿出了自己的新的页面特效。其中最牛叉的还是谷歌,如下图:

[[90061]]

可以用键盘控制的小游戏,看看它的源码:

  1. <div id="hplogo" tabindex="0" dir="ltr" aria-label="跨栏" style="cursor: pointer;">  
  2. <canvas style="position: absolute;" height="207" width="530"></canvas>  
  3. ..... 

canvas,html5....,拷贝它的代码还是有点难度了。

但是我在国外的网站里还是发现了一个我感兴趣的特效,就是腾讯微博里的"拉绳开关"的换肤效果,这个比较简单,我把代码“抠 ”了出来。

  

首先介绍小这个网页特效的效果,点击“London 2012”吊环图标,图标会下拉绳,释放鼠标后,页面背景会换成中国奥运军团的图 片,此时吊环下方,会有一个“还原”按钮,点击“还原”按钮,背景恢复到原来背景,继续点击拉绳吊环,背景图片会在不同的 奥运图片间切换,鼠标移到拉绳上方,鼠标变成剪刀样式,点击,吊环会以自由落体的方式坠落,最后消失。

以上效果我都拷贝出来了,还是比较简单的,源码如下:

首先还是目录结构:

main.css的代码:

  1. body {  
  2.     background-color:#999;  
  3.     color#333333;  
  4.     font12px/1.75 Tahoma,Arial,sans-serif;  
  5. }  
  6. body {  
  7.     background:url(../images/wrapbg_v0.0.1.jpg) no-repeat scroll center top #73CFF1;  
  8.     color#333333;  
  9.     font12px/1.75 Tahoma,Arial,sans-serif;  
  10.     height100%;  
  11. }  
  12. body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6pre, form, input, textarea, p, blockquote, th, td {  
  13.     margin0;  
  14.     padding0;  
  15. }  
  16. .nv_toogle_w {  
  17.     height0;  
  18.     margin0 auto;  
  19.     positionrelative;  
  20.     width960px;  
  21. }  
  22. a, .c_tx {  
  23.     text-decorationnone;  
  24. }  
  25. a, .c_tx {  
  26.     color#006A92;  
  27. }  
  28. .nv_toggle_btn, .nv_arrow_wpd, .nv_arrow_lab, .nv_arrow_message {  
  29.     background:url(../images/guide_icon.png) no-repeat scroll 0 0 transparent;  
  30. }  
  31. .nv_toggle_btn {  
  32.     background-position-195px 0;  
  33.     cursorpointer;  
  34.     displayblock;  
  35.     height111px;  
  36.     positionabsolute;  
  37.     right: -31px;  
  38.     text-indent-9999px;  
  39.     top: -35px;  
  40.     width23px;  
  41.     z-index5;  
  42. }  
  43. .nv_toggle_btn_oly2012 {  
  44.     backgroundurl("../images/nv_toggle_btn_oly2012.png"no-repeat scroll 0 0 transparent;  
  45.     height206px;  
  46.     right: -44px;  
  47.     top: -73px;  
  48.     width29px;  
  49. }  
  50. .headWrap a {  
  51.     color#C9C9C9;  
  52. }  
  53. .headWrap a:hover {  
  54.     text-decorationnone;  
  55. }  
  56. .nv_toggle_btn span {  
  57.     displayblock;  
  58. }  
  59. .nv_toggle_reset {  
  60.     color#FECCF3 !important;  
  61.     positionabsolute;  
  62.     right: -43px;  
  63.     top: 138px;  
  64. }  
  65. .nv_toggle_reset, .nv_toggle_reset span, .nv_toggle_reset b {  
  66.     displayblock;  
  67.     height26px;  
  68.     width27px;  
  69. }  
  70. .nv_toggle_reset span {  
  71.     cursorpointer;  
  72.     line-height26px;  
  73.     positionrelative;  
  74.     text-aligncenter;  
  75.     z-index5;  
  76. }  
  77. .nv_toggle_reset b {  
  78.     backgroundnone repeat scroll 0 0 #E33194;  
  79.     left: 0;  
  80.     opacity: 0.63;  
  81.     positionabsolute;  
  82.     top: 0;  
  83.     z-index0;  
  84. }  
  85. .nv_toggle_cut {  
  86.     cursorurl("http://mat1.gtimg.com/www/mb/images/cut_c.cur"), pointer;  
  87.     displayblock;  
  88.     height19px;  
  89.     positionabsolute;  
  90.     right: -44px;  
  91.     top: 0;  
  92.     width29px;  
  93.     z-index10;  

main.js的代码:

  1. var picInd = 0;  
  2. $(document).ready(function() {  
  3.     $("#nv_toogle_w").bind("mousedown",function(){   
  4.         $(this).animate({top:"20px"},"normal");  
  5.     });  
  6.     $("#nv_toogle_w").bind("mouseup",function(){  
  7.         getRandomNum();  
  8.         $("body").attr("class","");  
  9.         $("body").addClass("body" + picInd);  
  10.         $(this).animate({top:"0px"},"normal");  
  11.         $("#nv_toogle_w2").css("display","block");  
  12.     });  
  13.     $("#nv_toogle_w2").bind("click",function(){  
  14.         $("body").attr("class","");  
  15.         $("#nv_toogle_w2").css("display","none");  
  16.     });  
  17.     $("#nv_toggle_cut").bind("click",function(){  
  18.         $("#nv_toogle_w").animate({top:"300px"},"4000");  
  19.         $("a[boss='btnWideGuideBtn']").animate({opacity:"0"},"3000");  
  20.         $("#nv_toogle_w2").css("display","none").delay(6999);  
  21.     });  
  22. });  
  23.  
  24.  
  25. function getRandomNum(){  
  26.     while(true){  
  27.         var curInd = Math.floor(Math.random() * 8 + 1);  
  28.         if (picInd != 0 || picInd != curInd){  
  29.             picInd = curInd;  
  30.             break;      
  31.         }  
  32.     }  

qq01.html的代码:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  5. <title>QQ Study 01</title> 
  6. </head> 
  7. <script type="text/javascript" src="js/jquery-1.7.1.js"></script> 
  8. <script type="text/javascript" src="js/main.js"></script> 
  9. <link type="text/css" rel="stylesheet" href="css/main.css" /> 
  10. <style type="text/css"> 
  11. .body1{  
  12.     background:url(images/bg/ldyx.jpg) no-repeat fixed center top #EFEFEF;      
  13. }  
  14. .body2{  
  15.     background: url(images/bg/aycg_120802.jpg) no-repeat fixed center top #000000;  
  16. }  
  17. .body3{  
  18.     background: url(images/bg/jqsc.jpg) no-repeat fixed center top #000000;  
  19. }  
  20. .body4{  
  21.     background: url(images/bg/bg2.jpg) no-repeat fixed center top #1D1D1D;  
  22. }  
  23. .body5{  
  24.     background: url(images/bg/bg3.jpg) no-repeat fixed center top #1D1D1D;  
  25. }  
  26. .body6{  
  27.     background: url(images/bg/bg4.jpg) no-repeat fixed center top #1D1D1D;  
  28. }  
  29. .body7{  
  30.     background: url(images/bg/mlld.jpg) no-repeat fixed center top #429FDE;  
  31. }  
  32. .body8{  
  33.     background: url(images/bg/bg.jpg) no-repeat fixed center top #000000;  
  34. }  
  35. </style> 
  36. <body> 
  37.     <div class="nv_head_wrap"> 
  38.         <div title="拉一下换肤" style="top: 0px;" id="nv_toogle_w" class="nv_toogle_w"> 
  39.             <a boss="btnWideGuideBtn" class="nv_toggle_btn nv_toggle_btn_oly2012" 
  40.             href="#"> 
  41.                 <span> 
  42.                     new  
  43.                 </span> 
  44.             </a> 
  45.         </div> 
  46.         <div style="position:relative" class="nv_toogle_w"> 
  47.             <a id="nv_toogle_w2" style="display: none;" class="nv_toggle_reset" href="#"> 
  48.                 <span> 
  49.                     还原  
  50.                 </span> 
  51.                 <b> 
  52.                 </b> 
  53.             </a> 
  54.             <a id="nv_toggle_cut" class="nv_toggle_cut" title="永久关闭此功能" href="#"> 
  55.             </a> 
  56.         </div> 
  57.         <div> 
  58.         </div> 
  59.     </div> 
  60. </body> 
  61. </html> 

下载链接:http://files.cnblogs.com/sharpxiajun/myQQ.zip

原文链接:http://www.cnblogs.com/sharpxiajun/archive/2012/08/07/2626531.html

【编辑推荐】

  1. 如何优化你的JS代码
  2. 另一款有意思的JS图片放大镜
  3. 大部分人没用过的JS页面模板化
  4. 能说明你的JS技术很烂的五个原因
  5. 为何转向Spine.js的十个理由
责任编辑:张伟 来源: 夏天的森林的博客
相关推荐

2012-07-30 09:46:29

网络过载网络问题

2021-11-23 23:06:32

物联网奥运会技术

2011-12-10 19:55:41

Google

2012-07-26 13:41:30

伦敦奥运会CNZZ移动营销

2010-01-13 10:32:52

2012-07-27 17:01:33

CDN网宿科技

2022-06-01 17:04:32

戴尔

2011-01-28 09:29:42

2012奥运会科技实验室

2016-08-10 18:21:02

电子圈 奥运会

2012-08-16 16:41:50

大数据伦敦奥运会

2015-10-12 16:57:34

2012-06-29 10:45:55

开源技术架构

2020-03-04 10:21:19

东京奥运会黑客IT安全

2021-07-28 06:34:24

钓鱼网站东京奥运会网络安全

2012-07-30 15:16:33

云计算

2015-06-23 11:07:30

腾讯微博真相

2012-03-21 10:52:18

伦敦奥运会互联网视频直播

2021-07-22 10:32:02

戴尔科技集团存储

2012-07-04 13:25:30

2012-08-02 15:08:31

IBM超级电脑北京奥运会天气预报
点赞
收藏

51CTO技术栈公众号