サマリー:<!DOCTYPE html><html> <head> <title>下滑線跟隨導(dǎo)航</title> <meta charset="utf-8"/> <script type="text/javascript" src="j
<!DOCTYPE html>
<html>
<head>
<title>下滑線跟隨導(dǎo)航</title>
<meta charset="utf-8"/>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css">
*{padding:0;margin:0;}
ul {list-style: none;z-index:20;position:relative;font-size: 15px;}
li {float:left;cursor:pointer;width:100px;height: 30px;text-align:center;line-height:30px;color: #fff;font-weight: bold;}
.menu{width:1250px;position:relative;margin:25px auto;height:32px;box-shadow: 0 10px 20px #000;background: #AF3434;border-radius:13px; }
.cc{margin-left:350px;}
</style>
<script type="text/javascript">
$(function(){
$('li').hover(
function(){
$x=parseInt($(this).attr('name'))*100
$('.block').stop().animate({left:$x+'px'},300)
},
function(){
$('.block').stop().animate({left:'0px'},300)
}
)
})
</script>
</head>
<body>
<div class="menu">
<ul class="cc">
<li name="0">首頁</li>
<li name="1">菜單項(xiàng)一</li>
<li name="2">菜單項(xiàng)二</li>
<li name="3">菜單項(xiàng)三</li>
<li name="4">菜單項(xiàng)四</li>
</ul>
<div class="block" style="z-index:10;width:100px;height:2px;background:#fff;position:absolute;top:30px;margin-left:350px;"></div>
</div>
</body>
</html>
添削の先生:韋小寶添削時(shí)間:2019-02-11 17:32:23
先生のまとめ:代碼寫的也很完整!下劃線跟隨導(dǎo)航的效果在很多網(wǎng)站的導(dǎo)航中都會(huì)出現(xiàn)!課后沒事多練習(xí)練習(xí)