サマリー:總覺得好多地方 搞不太明白 看著懂 但是操作起來感覺吃力<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><style type="text/css">*{m
總覺得好多地方 搞不太明白 看著懂 但是操作起來感覺吃力
<!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標簽
function(){
$x=parseInt($(this).attr('name'))*100 //定義個變量 parseInt獲取this attr獲取內(nèi)部屬性 連接name 這句話就是給x定義個變量 給每個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>
添削の先生:天蓬老師添削時間:2018-12-21 16:22:33
先生のまとめ:很多同學(xué)都有這種問題,看起來懂,實際寫的時候又發(fā)現(xiàn)不太懂。實際上就是寫的太少了。寫多了就沒有這些問題了