您好,登錄后才能下訂單哦!
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>實例:jQuery彈性滑動導航菜單</title>
<style type="text/css">
body{ font-size:100%; font-family:"Microsoft YaHei","Arial"; background:#fff;}
#nav{ position:relative; width:832px; _width:835px; margin:100px auto 0 auto; border-bottom:2px #ddd solid;}
#nav .nav-menu{ height:50px;}
#nav .nav-menu a{ display:block; float:left; height:50px; padding:0 40px; line-height:50px; color:#666; font-size:16px; text-decoration:none;}
#nav .nav-current{ position:absolute; bottom:-2px; height:2px; overflow:hidden; background:#80b600;}
</style>
<script id="jquery_172" type="text/javascript" class="library" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
(function(){
var $navcur = $(".nav-current");
var $nav = $("#nav");
var current = ".current";
var itemW = $nav.find(current).innerWidth(); //默認當前位置寬度
var defLeftW = $nav.find(current).position().left; //默認當前位置Left值
//添加默認下劃線
$navcur.css({width:itemW,left:defLeftW});
//hover事件
$nav.find("a").hover(function(){
var index = $(this).index();//獲取滑過元素索引值
var leftW = $(this).position().left;//獲取滑過元素Left值
var currentW = $nav.find("a").eq(index).innerWidth();//獲取滑過元素Width值
$navcur.stop().animate({
left: leftW,
width: currentW
},300);
},function(){
$navcur.stop().animate({
left: defLeftW,
width: itemW
},300)
})
})();
});
</script>
</head>
<body>
<div id="nav">
<div class="nav-menu">
<a href="#" class="current">首頁</a>
<a href="#">了解我們</a>
<a href="#">產品展示</a>
<a href="#">服務報價</a>
<a href="#">最新消息</a>
<a href="#">聯系方式</a>
</div>
<div class="nav-current"></div>
</div>
</body>
</html>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。