jQuery实现仿腾讯微博滑出效果报告每日天气的方法
本文实例讲述了jQuery实现仿腾讯微博滑出效果报告每日天气的方法。分享给大家供大家参考。具体分析如下:
这是仿腾讯微博滑出效果的每日天气代码,鼠标放上去,天气内容将从左向右滑出来,像开抽屉一样,本动画效果流畅,当然少不了jQuery的功劳,本代码使用了1.6.2版本的jQuery插件来实现这一功能。
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>仿腾讯微博的每日天气效果</title>
<styletype="text/css">
.weather{
width:500px;height:100px;margin:0auto;
position:relative;color:#fff;text-align:center;
overflow:hidden;
}
.weather_main{
width:99px;border-right:solid1px#fff;
float:left;background:#F03;text-align:center;
position:relative;z-index:2;
}
.weather_mainstrong{
line-height:100px;
}
.weather_mainstronga{
border-bottom:solid2px#fff;cursor:pointer;
}
.alert{
width:400px;height:100px;position:absolute;
left:-400px;top:0;background:#F03;
}
</style>
<scriptsrc="jquery-1.6.2.min.js"type="text/javascript"></script>
<scripttype="text/javascript">
$(document).ready(function(){
$(".weather_main").hover(function(){
$(".alert").animate({left:"100px"},1000);
returnfalse;
},function(){
$(".alert").animate({left:"-400px"},1000);
returnfalse;
})
})
</script>
</head>
<body>
<divclass="weather">
<divclass="weather_main">
<strong><a>深圳</a></strong>
</div><!--weather_main-->
<divclass="alert">
<p>如果云知道,多想凉风来做伴~</p>
<p><a>提醒好友</a></p>
</div>
</div><!--weatherbox-->
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。