电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 821 人浏览分享

仿谷歌主页js动画效果实现代码

 关闭 [复制链接]
821 0

  1. <p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html
  4. xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta
  7. http-equiv="Content-Type" content="text/html; charset=utf-8"
  8. />
  9. <title>谷歌主页动画</title>
  10. <style
  11. type="text/css">
  12. .animate{
  13. height:156px;
  14. width:97px;
  15. background:url(images/gumby11-gumby.jpg)
  16. no-repeat;
  17. background-position:-15581px
  18. center;
  19. }
  20. </style>
  21. <script type="text/javascript"
  22. src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  23. <script
  24. type="text/javascript">
  25. $(function(){
  26. var offset =
  27. -15678;
  28. $('#start').click(function(){
  29.   var timer =
  30. setInterval(function(){
  31.    offset += 98;
  32.    
  33. $('#animate').css({
  34.     'background-position':offset + 'px
  35. center'
  36.    });
  37.    if(offset >
  38. 0){
  39.     clearInterval(timer);
  40.    }
  41.   
  42. },50);
  43.   
  44. $(this).hide();
  45. });
  46. });
  47. </script>
  48. </head>
  49. <body>
  50. <div
  51. id="animate" class="animate"></div>
  52. <a id="start"
  53. href="javascript:void(0)">动起来吧!</a>
  54. </body>
  55. </html></p>
复制代码

您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

23

粉丝

2901

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.