首页 > 语言 > JavaScript > 正文

jQuery实现仿腾讯微博滑出效果报告每日天气的方法

2024-05-06 16:19:53
字体:大 中 小
来源:转载
供稿:网友

这篇文章主要介绍了jQuery实现仿腾讯微博滑出效果报告每日天气的方法,涉及jQuery鼠标事件及css样式操作技巧,需要的朋友可以参考下

本文实例讲述了jQuery实现仿腾讯微博滑出效果报告每日天气的方法。分享给大家供大家参考。具体分析如下:

这是仿腾讯微博滑出效果的每日天气代码,鼠标放上去,天气内容将从左向右滑出来,像开抽屉一样,本动画效果流畅,当然少不了jQuery的功劳,本代码使用了1.6.2版本的jQuery插件来实现这一功能。

 

 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <html xmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  6. <title>仿腾讯微博的每日天气效果</title> 
  7. <style type="text/css"> 
  8. .weather{ 
  9. width:500px;height:100px;margin:0 auto; 
  10. position:relative;color:#fff;text-align:center; 
  11. overflow:hidden; 
  12. } 
  13. .weather_main{ 
  14. width:99px;border-right:solid 1px #fff; 
  15. float:left;background:#F03;text-align:center; 
  16. position:relative;z-index:2; 
  17. } 
  18. .weather_main strong{ 
  19. line-height:100px; 
  20. } 
  21. .weather_main strong a{ 
  22. border-bottom:solid 2px #fff;cursor:pointer; 
  23. } 
  24. .alert{ 
  25. width:400px;height:100px;position:absolute; 
  26. left:-400px;top:0;background:#F03; 
  27. } 
  28. </style> 
  29. <script src="jquery-1.6.2.min.js" type="text/javascript"></script> 
  30. <script type="text/javascript"> 
  31. $(document).ready(function(){ 
  32. $(".weather_main").hover(function(){ 
  33. $(".alert").animate({left:"100px"},1000); 
  34. return false; 
  35. },function(){ 
  36. $(".alert").animate({left:"-400px"},1000); 
  37. return false; 
  38. }) 
  39. }) 
  40. </script> 
  41. </head> 
  42. <body> 
  43. <div class="weather"> 
  44. <div class="weather_main"> 
  45. <strong><a>深圳</a></strong> 
  46. </div><!--weather_main--> 
  47. <div class="alert"> 
  48. <p>如果云知道,多想凉风来做伴~</p> 
  49. <p><a>提醒好友</a></p> 
  50. </div> 
  51. </div><!--weather box--> 
  52. </body> 
  53. </html> 

希望本文所述对大家的jQuery程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选