慕粉3760367
2016-10-15 18:15
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>练习</title>
<style type="text/css" media="screen">
*{padding:0;margin:0;}
ul{list-style: none;margin-left: 20px;}
li{float: left;}
a{text-decoration:none;height:40px;width:100px;background-color: #ccc;display:block;text-align: center;line-height: 40px;margin-bottom: 15px;}
a:hover{background-color: #ecc;color: #fff;
}
</style>
<script type="text/javascript">
window.onload=function(){
var aA=document.getElementsByTagName('a');
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.offetWidth>=130){
clearInterval(This.time);
}
},30);
}
aA[i].onmouseout=function(){
var This=this;
This.time=setInterval(function(){
This.style.width=This.offsetWidth-8+"px";
if(This.offetWidth<=100){
This.style.width="100px";
clearInterval(This.time);
}
},30);
}
}
}
</script>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
<ul>
<li><a href="" title="">首页</a></li>
<li><a href="" title="">资讯</a></li>
<li><a href="" title="">新闻</a></li>
<li><a href="" title="">产品展示</a></li>
</ul>
</body>
</html>
没有暂停
JS动画效果
113925 学习 · 1443 问题
相似问题
回答 2
回答 1
回答 2
回答 1
回答 1