jQuery實(shí)現(xiàn)帶滑動(dòng)條的菜單效果代碼
本文實(shí)例講述了jQuery實(shí)現(xiàn)帶滑動(dòng)條的菜單效果代碼。分享給大家供大家參考。具體如下:
這是一款帶滑動(dòng)條的jQuery滑動(dòng)菜單,菜單下邊有一個(gè)藍(lán)色的線條,鼠標(biāo)移上哪里它就跟向哪里,可以指引當(dāng)前菜單的位置,另外,動(dòng)畫效果是基于jquery的animate(),對此有興趣學(xué)習(xí)的正好可參考下代碼。
運(yùn)行效果截圖如下:

在線演示地址如下:
http://demo.jb51.net/js/2015/jquery-move-buttom-line-style-codes/
具體代碼如下:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312">
<title>帶滑動(dòng)條的jQuery滑動(dòng)菜單</title>
<style>
body{ font:12px/1.5 Arial,\5b8b\4f53,sans-serif;background:#fff; color:#333; position:relative}
.header { width:990px; min-width:990px; margin:0 auto; height:68px; position:relative; z-index:200; overflow:hidden}
.headerTab { height:44px; padding:24px 0 0 0; position:relative; width:990px; min-width:990px; margin:0 auto; }
.headerTab a { padding:0 5px; float:left; font-size:14px; color:#333; height:42px; overflow:hidden; line-height:44px;font-family:\5FAE\8F6F\96C5\9ED1,\5B8B\4F53; margin-left:10px; display:inline}
.headerTab a:hover { text-decoration:none; color:#333}
.headerTab .tabLine { position:absolute; top:66px; height:2px; background:#35b0f2; left:0; width:100%; overflow:hidden; font-size:0; line-height:0;}
</style>
</head>
<body>
<div class="headerTab" id="headerTab"><a href="#" title="">腳本之家</a><a href="#" title="">下載中心</a><a href="#" title="">最新更新</a><a href="#" title="">廣告中心</a><a href="#" target="_blank" title="">Delphi源碼</a><a href="#" target="_blank" title="">VC++源碼</a><a href="#" title="">更新日志</a><i class="tabLine"></i></div>
</body>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script>
var headerTabArray = $("#headerTab a"),headTabLine = $("#headerTab .tabLine"),tabIndex,headerTabArrayLength = headerTabArray.length,headerTabWidthArray = [],headerTabPositonArray = [],defaultNum = 0;
for(var i=0;i<headerTabArrayLength;i++){
headerTabWidthArray[i] = headerTabArray.eq(i).width() + 10;
headerTabPositonArray[i] = headerTabArray.eq(i).position().left + 10;
}
headerTabArray.mouseover(function(){
$("#headerTab i:animated").stop();
tabIndex = $(this).index();
headTabLine.animate({width:headerTabWidthArray[tabIndex],left:headerTabPositonArray[tabIndex]},300);
})
headerTabArray.mouseout(function(){
$("#headerTab i:animated").stop();
tabIndex = $(this).index();
headTabLine.animate({width:headerTabWidthArray[defaultNum],left:headerTabPositonArray[defaultNum]},300);
})
defaultNum = 0;
headTabLine.animate({width:headerTabWidthArray[defaultNum],left:headerTabPositonArray[defaultNum]},300);
</script>
</html>
希望本文所述對大家的jquery程序設(shè)計(jì)有所幫助。
- jQuery實(shí)現(xiàn)MSN中文網(wǎng)滑動(dòng)Tab菜單效果代碼
- jquery實(shí)現(xiàn)標(biāo)題字體變換的滑動(dòng)門菜單效果
- jQuery實(shí)現(xiàn)帶延遲效果的滑動(dòng)菜單代碼
- 基于jQuery實(shí)現(xiàn)的向下滑動(dòng)二級菜單效果代碼
- jquery實(shí)現(xiàn)左右滑動(dòng)菜單效果代碼
- jQuery實(shí)現(xiàn)帶幻燈的tab滑動(dòng)切換風(fēng)格菜單代碼
- jQuery實(shí)現(xiàn)菜單式圖片滑動(dòng)切換
- jQuery實(shí)現(xiàn)可用于博客的動(dòng)態(tài)滑動(dòng)菜單
- jquery實(shí)現(xiàn)最簡單的滑動(dòng)菜單效果代碼
相關(guān)文章
jQuery使用$.each遍歷json數(shù)組的簡單實(shí)現(xiàn)方法
這篇文章主要介紹了jQuery使用$.each遍歷json數(shù)組的簡單實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了each方法遍歷json數(shù)組的實(shí)現(xiàn)技巧與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-04-04
基于jquery的button默認(rèn)enter事件(回車事件)。
這里我介紹一下,button按鈕默認(rèn)回車(enter)事件。如果大家可以用submit,就不用看以下代碼,因?yàn)閟ubmit可以直接默認(rèn)回車事件(enter)2011-05-05
JQuery EasyUI 結(jié)合ztrIee的后臺(tái)頁面開發(fā)實(shí)例
下面小編就為大家?guī)硪黄狫Query EasyUI 結(jié)合ztrIee的后臺(tái)頁面開發(fā)實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09
jquery的冒泡事件的阻止與允許(三種實(shí)現(xiàn)方法)
冒泡或默認(rèn)的事件發(fā)生,在某些時(shí)候是不需要的,在此就需要一些可以阻止冒泡和默認(rèn)的事件的方法,本文介紹三種方法做到不同程度的阻止,感興趣的朋友可以了解下,或許對你了解冒泡事件有所幫助2013-02-02
基于jQuery實(shí)現(xiàn)點(diǎn)擊彈出層實(shí)例代碼
基于jquery實(shí)現(xiàn)點(diǎn)擊鏈接彈出層效果,其基本實(shí)現(xiàn)原理是這樣的:jquery操作DOM元素。對層樣式的設(shè)置。將display:設(shè)置為none;讓層隱藏;對jq點(diǎn)擊彈出層相關(guān)知識感興趣的朋友一起學(xué)習(xí)吧2016-01-01
基于jQuery實(shí)現(xiàn)文本框縮放以及上下移動(dòng)功能
這里給大家分享一段個(gè)人覺著非常實(shí)用也經(jīng)常用于項(xiàng)目中的代碼,本代碼基于jQuery實(shí)現(xiàn)了文本框縮放以及上下移動(dòng)功能,給需要的網(wǎng)友們參考下吧2014-11-11
解析prototype,JQuery中跳出each循環(huán)的方法
這篇文章主要介紹了在prototype,JQuery中跳出each循環(huán)的方法。需要的朋友可以過來參考下,希望對大家有所幫助2013-12-12
asp.net下使用jquery 的ajax+WebService+json 實(shí)現(xiàn)無刷新取后臺(tái)值的實(shí)現(xiàn)代碼
asp.net下使用jquery 的ajax+WebService+json 實(shí)現(xiàn)無刷新取后臺(tái)值的實(shí)現(xiàn)代碼 ,比頁面刷新更好,用戶體驗(yàn)更好,需要的朋友可以參考下。2010-09-09

