国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery實現背景彈性滾動的導航效果

2019-11-20 09:50:13
字體:
來源:轉載
供稿:網友

本文實例講述了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>背景彈性滾動的導航效果</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>預覽效果時左下角會提示錯誤,而且看不到效果,刷新一下就可以看到效果了;當然,在實際使用中,不會出現這樣的問題。<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:這里再為大家推薦幾款代碼格式化、美化工具,相信大家在以后的開發過程中會用得到:

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

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

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

json代碼在線格式化/美化/壓縮/編輯/轉換工具:
http://tools.VeVB.COm/code/jsoncodeformat

在線JSON代碼檢驗、檢驗、美化、格式化工具:
http://tools.VeVB.COm/code/json

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

希望本文所述對大家jQuery程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湖北省| 宣汉县| 凤山市| 湖口县| 台南市| 沙洋县| 阜宁县| 望江县| 德令哈市| 礼泉县| 金溪县| 湟中县| 海南省| 浦县| 云霄县| 凤台县| 莒南县| 松桃| 正蓝旗| 建昌县| 广宗县| 繁峙县| 商河县| 南京市| 元阳县| 舒城县| 黔西县| 黄平县| 宁安市| 贡觉县| 雷州市| 神池县| 鸡泽县| 沾化县| 蚌埠市| 富平县| 余姚市| 泽普县| 宜章县| 绥芬河市| 榆中县|