本文實例講述了jQuery實現仿微軟首頁感應鼠標變化滑動窗口效果。分享給大家供大家參考。具體如下:
這是一款jQuery仿微軟首頁感應鼠標變化的滑動窗口,鼠標放上後,窗口會向左拉長,鼠標移走後恢復原樣,是在微軟官方網站發現的,看了看代碼,覺得很容易就扣下來,不敢獨享。
運行效果截圖如下:

具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery仿微軟首頁感應鼠標變化的滑動窗口</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<style type="text/css">
.box{width:100px;height:100px;position:absolute;right:0;color:#fff;}
.box1{top:100px;background:#000;}
.box2{top:250px;background:#333;}
.box3{top:400px;background:#666;}
.box4{top:550px;background:#999;}
</style>
<script type="text/javascript" src="jquery1.3.2.js"></script>
</head>
<body>
<div class="box box1">應用</div>
<div class="box box2">下載</div>
<div class="box box3">Windows Phone</div>
<div class="box box4">Office</div>
<script type="text/javascript">
$('.box').each(function(){
$(this).hover(function(){
$(this).stop().animate({width:'150'},1000);
},function(){
$(this).stop().animate({width:'100'},1000);
});
});
</script>
</body>
</html>
希望本文所述對大家的jQuery程序設計有所幫助。