abstract:總覺(jué)得好多地方 搞不太明白 看著懂 但是操作起來(lái)感覺(jué)吃力<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><style type="text/css">*{m
總覺(jué)得好多地方 搞不太明白 看著懂 但是操作起來(lái)感覺(jué)吃力
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{margin:0px;padding: 0px;list-style: none;}
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;}
.top{width:500px;position:relative;margin:20px auto;height:32px;box-shadow: 0 2px 20px #000;background: #AF3434;border-radius:3px}
.book{z-index: 10;width: 65px;height: 2px;background-color: #fff;margin-left: 7px;position: absolute;top: 30px;}
</style>
<script type="text/javascript"src="js/jquery-3.3.1.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
$('li').hover( //獲取li標(biāo)簽
function(){
$x=parseInt($(this).attr('name'))*100 //定義個(gè)變量 parseInt獲取this attr獲取內(nèi)部屬性 連接name 這句話就是給x定義個(gè)變量 給每個(gè)name*100
$('.book').stop().animate({left:$x+'px'},300)//book為下方的下劃線 stop停止
},
function(){
$('.book').stop().animate({left:'0px'},500)
}
)
})
</script>
<div>
<ul>
<li name="0">博客1</li>
<li name="1">博客1</li>
<li name="2">博客1</li>
<li name="3">博客1</li>
<li name="4">博客1</li>
<li name="5">博客1</li>
</ul>
<div></div>
</div>
</body>
</html>
Correcting teacher:天蓬老師Correction time:2018-12-21 16:22:33
Teacher's summary:很多同學(xué)都有這種問(wèn)題,看起來(lái)懂,實(shí)際寫(xiě)的時(shí)候又發(fā)現(xiàn)不太懂。實(shí)際上就是寫(xiě)的太少了。寫(xiě)多了就沒(méi)有這些問(wèn)題了