<!DOCTYPE?html>
<html>
<head>
<meta?charset="UTF-8">
<title>導航欄的制作</title>
<style>
*{margin:0?;padding:?0;?font-size:?15px}
ul{
list-style:?none;
margin-right:?5px;
margin-top:?50px;?
}
li{float:left;}
a{
text-decoration:?none;
display:?block;
width:?70px;
height:?20px;
text-align:?center;
background-color:?#ccc;
border:?2px?solid?black;
padding:?5px?2px;
}
.on,a:hover{background:?yellow;?color:green;?height:30px;?line-height:?30px;?margin-top:?-10px;}
</style>
<script>
window.onload=function()
{
var?aA=document.getElementsByTagName("a");
for(var?i=0;i<aA.length;i++)
{
aA[i].onmouseover=function(){
clearInterval(this.time);
var?This=this?;
This.time=setInterval(function(){
This.style.width=This.offsetWidth+8+"px";
if(This.offsetWidth>=100){
clearInterval(This.time)
}
},30)
}
aA[i].onmouseout=function(){
clearInterval(this.time);
var?This=this?;
This.time=setInterval(function(){
This.style.width=This.offsetWidth-8+"px";
if(This.offsetWidth<=70){
This.style.width?=?"70px";
clearInterval(This.time)
}
},30)
}
}
}
</script>
</head>
<body>
<ul>
<li><a?href="#">首頁</a></li>
</ul>
<ul>
<li><a?href="#">新聞快訊</a></li>
</ul>
<ul>
<li><a?href="#">產品展示</a></li>
</ul>
<ul>
<li><a?href="#">意見反饋</a></li>
</ul>
<ul>
<li><a?href="#">聯系我們</a></li>
</ul>
</body>
</html>
我這個導航欄動畫效果只能變大,不能變回去為什么?。???
lulubiu
2017-04-23 19:08:42