亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

下劃線跟隨導(dǎo)航

原創(chuàng) 2018-11-29 18:43:40 194
摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>下劃線跟隨導(dǎo)航</title> <script type="text/javascript" src="jque
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>下劃線跟隨導(dǎo)航</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<style>
*{margin:0px;padding:0px;}
.menu{
width:500px;
height:32px;
background: black;
margin:20px auto;
box-shadow: 0px 2px 20px;
border-radius: 3px;
position: relative;
}

ul li{

float:left;
width:100px;
height:30px;
line-height: 30px;
color:#ccc;
font-weight: bold;
text-align: center;
cursor: pointer;
list-style: none;
font-size:15px;
}

.block{
width:100px;
height:2px;
background: #fff;
top:30px;
position: absolute;
z-index: 10;

}

</style>

<script type="text/javascript">
$(function(){
$('li').hover(function(){
$x=parseInt($(this).attr('name'))*100;
$('.block').stop().animate({left:$x+'px'},500)
},
function(){$('.block').stop().animate({left:'0px'},500)
})
})


</script>
</head>
<body>
<div class="menu>
<ul>
<li name="0">首頁</li>
<li name="1">PHP中文網(wǎng)</li>
<li name="2">滅絕師太</li>
<li name="3">獨(dú)孤九劍</li>
<li name="4">西門大官人</li>
</ul>
<div class="block"></div>
</div>
</body>
</html>

注意相對(duì)定位和絕對(duì)定位的使用:
    使用絕對(duì)定位的時(shí)候,定位的參照元素是包含定位屬性的父元素,
    如果沒有父元素,則元素按照<body>元素的位置,確定顯示位置。
z-index屬性的使用:
    z-index 僅能在定位元素上奏效
 
hover(over,out)
    over:鼠標(biāo)移上元素上要觸發(fā)的一個(gè)函數(shù)
    out:鼠標(biāo)移出元素上要觸發(fā)的一個(gè)函數(shù)
   語法:
   $(document).ready(function(){
       $("selector").hover(function(){},function(){})
       })


批改老師:滅絕師太批改時(shí)間:2018-11-30 09:16:05
老師總結(jié):很簡(jiǎn)單的動(dòng)畫效果,思路清楚以后很容易就完成了,要自己試著找點(diǎn)案例把知識(shí)點(diǎn)運(yùn)用起來

發(fā)布手記

熱門詞條