输入script后 导航栏也没有收缩
<!DOCTYPE HTML>
<html>
<head>
<meta charest="utf-8">
</head>
<style type="text/css">
*{margin:0 padding:0;font-size: 14px;}
ul{list-style: none;height: 50px;padding-left: 30px;border-bottom: 5px solid #f60}
li{float:left;margin-top: 20px}
a{text-decoration: none;display: block;height: 30px;line-height: 30px;width: 120px;background: #ccc;margin-bottom: 1px;text-align: center;}
.on,a:hover{color: red;background:blue;height: 40px;line-height:40px;margin-top: -10px} //margin可以用负值 向相反方向移动
</style>
<script >
window.onload=function(){
var aA=document.getElementsByTagName('aA');
for (var i =0;i < aA.length;i++){
aA[i].onmouseover=function(){
var This=this;
This.time=setInterval(function(){
This.style.width=This.offsetwidth+8+"px";
if (This.offsetwidth>=160){
clearInterval(This.time)
}
},30)
}
}
}
</script>
<body >
<ul >
<li ><a class="on" href="#">首 页</a></li>
<li ><a href="#">新闻快讯</a></li>
<li ><a href="#">产品展示</a></li>
<li ><a href="#">售后服务</a></li>
<li ><a href="#">联系我们</a></li>
</ul>
</body>
</html>