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

jQuery實(shí)現(xiàn)背景彈性滾動(dòng)的導(dǎo)航效果

 更新時(shí)間:2016年06月01日 12:35:44   作者:鄭文亮  
這篇文章主要介紹了jQuery實(shí)現(xiàn)背景彈性滾動(dòng)導(dǎo)航效果的方法,涉及jQuery動(dòng)態(tài)操作頁(yè)面元素樣式的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)背景彈性滾動(dòng)的導(dǎo)航效果。分享給大家供大家參考,具體如下:

<!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>背景彈性滾動(dòng)的導(dǎo)航效果</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<!--把下面代碼加到<head>與</head>之間-->
<style type="text/css">
.nav-wrap {
margin: 0 auto;
background-color: #121212;
border-top: 1px solid #FFF;
border-bottom: 1px solid #FFF;
}
.group:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
*:first-child+html .group { /* IE7 */
zoom: 1;
}
#example {
width: 960px;
margin: 0 auto;
list-style: none;
position: relative;
}
#example li {
display: inline;
}
#example li a {
position: relative;
z-index: 200;
color: #AAA;
font-size: 14px;
display: block;
float: left;
padding: 12px 10px 10px 10px;
text-decoration: none;
text-transform: uppercase;
}
#example li a:hover {
color: #FFF;
}
#example #magic-line-two {
width: 100px;
position: absolute;
top: 0;
left: 0;
background: #666;
z-index: 100;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.current a {
color: #FFF !important;
}
</style>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(function(){
var $el, leftPos, newWidth,
$mainNav = $("#example");
/*
EXAMPLE
*/
$mainNav.append("<li id='magic-line-two'></li>");
var $magicLineTwo = $("#magic-line-two");
$magicLineTwo
.width($(".current").width())
.height($mainNav.height())
.css("left", $(".current a").position().left)
.data("origLeft", $(".current a").position().left)
.data("origWidth", $magicLineTwo.width())
.data("origColor", $(".current a").attr("rel"));
$("#example li").find("a").hover(function() {
$el = $(this);
leftPos = $el.position().left;
newWidth = $el.parent().width();
$magicLineTwo.stop().animate({
left: leftPos,
width: newWidth,
backgroundColor: $el.attr("rel")
})
}, function() {
$magicLineTwo.stop().animate({
left: $magicLineTwo.data("origLeft"),
width: $magicLineTwo.data("origWidth"),
backgroundColor: $magicLineTwo.data("origColor")
});
});
});
</script>
</head>
<body>
預(yù)覽效果時(shí)左下角會(huì)提示錯(cuò)誤,而且看不到效果,刷新一下就可以看到效果了;當(dāng)然,在實(shí)際使用中,不會(huì)出現(xiàn)這樣的問(wèn)題。<br>
<!--把下面代碼加到<body>與</body>之間-->
<div class="nav-wrap">
<ul class="group" id="example">
<li class="current"><a href="#" _fcksavedurl="#">Home</a></li>
<li><a href="#" _fcksavedurl="#">About me</a></li>
<li><a href="#" _fcksavedurl="#">Our Team</a></li>
<li><a href="#" _fcksavedurl="#">Portfolio</a></li>
<li><a href="#" _fcksavedurl="#">The Show</a></li>
<li><a href="#" _fcksavedurl="#">Videos</a></li>
<li><a href="#" _fcksavedurl="#">CSS/HTML</a></li>
<li><a href="#" _fcksavedurl="#">jQuery</a></li>
<li><a href="#" _fcksavedurl="#">Navigation</a></li>
<li><a href="#" _fcksavedurl="#">Wordpress</a></li>
<li><a href="#" _fcksavedurl="#">Contact</a></li>
</ul>
</div>
</body>
</html>

PS:這里再為大家推薦幾款代碼格式化、美化工具,相信大家在以后的開(kāi)發(fā)過(guò)程中會(huì)用得到:

在線JavaScript代碼美化、格式化工具:
http://tools.jb51.net/code/js

JavaScript壓縮/格式化/加密工具:
http://tools.jb51.net/code/jscompress

XML代碼在線格式化美化工具:
http://tools.jb51.net/code/xmlcodeformat

json代碼在線格式化/美化/壓縮/編輯/轉(zhuǎn)換工具:
http://tools.jb51.net/code/jsoncodeformat

在線JSON代碼檢驗(yàn)、檢驗(yàn)、美化、格式化工具:
http://tools.jb51.net/code/json

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

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

相關(guān)文章

  • jquery中的過(guò)濾操作詳細(xì)解析

    jquery中的過(guò)濾操作詳細(xì)解析

    這篇文章主要介紹了jquery中的過(guò)濾操作。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助
    2013-12-12
  • jQuery插件HighCharts實(shí)現(xiàn)氣泡圖效果示例【附demo源碼】

    jQuery插件HighCharts實(shí)現(xiàn)氣泡圖效果示例【附demo源碼】

    這篇文章主要介紹了jQuery插件HighCharts實(shí)現(xiàn)氣泡圖效果,結(jié)合完整實(shí)例形式分析了jQuery插件HighCharts繪制氣泡圖的實(shí)現(xiàn)技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下
    2017-03-03
  • jQuery中trigger()方法用法實(shí)例

    jQuery中trigger()方法用法實(shí)例

    這篇文章主要介紹了jQuery中trigger()方法用法,實(shí)例分析了trigger()方法的功能、定義及觸發(fā)匹配元素指定類型事件的使用技巧,需要的朋友可以參考下
    2015-01-01
  • 利用jquery實(shí)現(xiàn)瀑布流3種案例

    利用jquery實(shí)現(xiàn)瀑布流3種案例

    這篇文章主要為大家詳細(xì)介紹了利用jquery實(shí)現(xiàn)瀑布流2種案例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • jQuery取消ajax請(qǐng)求的方法

    jQuery取消ajax請(qǐng)求的方法

    這篇文章主要介紹了jQuery取消ajax請(qǐng)求的方法,可實(shí)現(xiàn)在Ajax請(qǐng)求超時(shí)的情況下取消請(qǐng)求的功能,需要的朋友可以參考下
    2015-06-06
  • jquery動(dòng)畫1.加載指示器

    jquery動(dòng)畫1.加載指示器

    動(dòng)畫效果對(duì)于豐富網(wǎng)站的交互體驗(yàn)起到了不可或缺的作用,他可以讓你的站點(diǎn)更酷,更吸引人
    2012-08-08
  • JavaScript和JQuery實(shí)用代碼片段(一)

    JavaScript和JQuery實(shí)用代碼片段(一)

    JavaScript和JQuery實(shí)用代碼片段,喜歡學(xué)習(xí)jquery的朋友可以參考下。
    2010-04-04
  • 最新評(píng)論