abstrak:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>jQuery的動畫效果--下劃線跟隨導(dǎo)航</title> <script type="text/javascript" src="
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery的動畫效果--下劃線跟隨導(dǎo)航</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<style type="text/css">
*{margin:0px;padding:0px;}
.nav{width:655px;height:48px;background:#272822;position:relative; margin:0px auto;border-radius: 10px;margin-top:40px;box-shadow: 0px 2px 20px #272822;}
ul{list-style:none;position: relative;z-index: 20px;}
li{float:left;line-height: 48px;width:130px;font-size:16px;font-weight:bold;color:#fff;border-right: 1px solid #fff;text-align:center;cursor: pointer;}
li:nth-child(5){border-right:none;}
.xhx{width:130px;height:3px;background:#29B452;z-index: 10px;position: absolute;top:45px;}
</style>
<script type="text/javascript">
$(function(){
$('li').hover(function(){
$x=parseInt($(this).attr('name'))*130
$('.xhx').stop().animate({left:$x+'px'},300)
},
function(){
$('.xhx').stop().animate({left:'0px'},300)
}
)
})
</script>
</head>
<body>
<div class="nav">
<ul>
<li name="0">首頁</li>
<li name="1">企業(yè)簡介</li>
<li name="2">新聞中心</li>
<li name="3">產(chǎn)品中心</li>
<li name="4">聯(lián)系我們</li>
</ul>
<div class="xhx"></div>
</div>
</body>
</html>
Guru membetulkan:韋小寶Masa pembetulan:2019-02-26 13:03:01
Rumusan guru:寫的很不錯(cuò) 這種效果看上去就可以讓導(dǎo)航高大上一點(diǎn)