欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)的導(dǎo)航動(dòng)畫(huà)效果(附demo源碼)

 更新時(shí)間:2016年04月01日 10:01:43   作者:xiao張  
這篇文章主要介紹了jQuery實(shí)現(xiàn)的導(dǎo)航動(dòng)畫(huà)效果,可實(shí)現(xiàn)導(dǎo)航條的底部橫條隨鼠標(biāo)移動(dòng)的效果,涉及jQuery針對(duì)鼠標(biāo)事件的響應(yīng)及頁(yè)面元素樣式動(dòng)態(tài)變換的相關(guān)技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)的導(dǎo)航動(dòng)畫(huà)效果。分享給大家供大家參考,具體如下:
經(jīng)常在網(wǎng)上看到的,鼠標(biāo)在導(dǎo)航上移動(dòng)時(shí),導(dǎo)航底部的橫條會(huì)自動(dòng)移動(dòng)到鼠標(biāo)懸浮的導(dǎo)航項(xiàng)上。

效果如下圖:

利用jquery的 animate 函數(shù),很好實(shí)現(xiàn)。代碼很簡(jiǎn)單!

代碼如下:

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>測(cè)試</title>
 <script src="jquery-1.9.1.min.js"></script>
</head>
<body>
<div class="nav" style="margin: 100px auto; width:960px;">
<a class="active" href="#">首頁(yè)</a>
<a href="#">產(chǎn)品</a>
<a href="#">新聞中心</a>
<a href="#">關(guān)于我們</a>
<a href="#">聯(lián)系我們</a>
<a href="#">首頁(yè)</a>
<a href="#">首頁(yè)</a>
<div class="line"></div>
</div>
<style>
.nav{
 position:relative;
}
.nav a{
 padding:10px 20px;
 border-bottom:solid 3px #fff;
 text-decoration: none;
 color:#666;
}
.nav a:hover{
 color:#66f;
}
.nav .active, .nav .active:hover{
 color:#f33;
}
.nav .line{
 position:absolute;
 border-top:solid 2px red;
 width:0;
 left:0;
 top:0;
}
</style>
<script>
function navLine(o, bo)
{
 var x = '' + (o.position().top + o.outerHeight() - 2) + 'px';
 var y = '' + o.position().left + 'px';
 var w = '' + o.outerWidth() + 'px';
 var h = '2px';
 $('.nav .line').stop();
 if (bo)
 {
  $('.nav .line').css({width:w, height:h, top:x, left:y});
 }
 else
 {
  $('.nav .line').animate({width:w, height:h, top:x, left:y});
 }
}
$(function(){
 navLine($('.nav .active'), true);
 $('.nav a').hover(function(){
  navLine($(this));
 }, function(){
  navLine($('.nav .active'));
 });
});
</script>
</body>
</html>

完整實(shí)例代碼點(diǎn)擊此處本站下載

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《jQuery拖拽特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見(jiàn)經(jīng)典特效匯總》、《jQuery動(dòng)畫(huà)與特效用法總結(jié)》、《jquery選擇器用法總結(jié)》及《jQuery常用插件及用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論