猿问

没有伸缩效果是怎么回事

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>导航菜单</title>发布(Ctrl+Enter)

<style>

*{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-color:#ccc;margin-bottom:1px;text-align:center;}

.on,a:hover{color:#fff;background-color:#F60;height:30px;line-height:30px}   /*鼠标经过的效果*/

</style>

<script>

window.onload=function(){

var aA=document.getElementsByTagName('a');

for(var i=o;i<aA.length;i++){

aA[i].onmouseover=function(){

var This=this;

clearInterval(This.time);

This.time=setInterval (function(){

   This.style.width=This.offsetWidth+8+"px";

if(This.offsetWidth>=160)

clearInterval(This.time);

},30)

}

aA[i].onmouseout=function(){

clearInterval(this.time);

var This=this;

this.this=setINterval(function(){

This.style.width=This.offsetWidth-8+"px";

if(This.offsetWidth<=100){

This.style.width='100px';

clearInterval(This.time);

}

},30)

}

}

}

</script>

</head>

<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>


遥逝
浏览 1301回答 1
1回答
随时随地看视频慕课网APP
我要回答