為什么不能伸縮
<style>
*{margin: 0; padding: 0;}
ul{list-style: none;border-bottom:5px solid #F60;height:50px;padding-left:30px}
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 =0;i<aA.length;i++){
aA[i].onmuseover=function(){
var This = this;
This.time=setInterval(function(){
This.style.width=This.offsetWidth+8+"px";
if(This.offsetWidth>=160){
clearInterval(This.time)
}
},30)
}
}
}
</script>
</head>
<body>
<ul>
? ? <li><a class="on" href="#">首 ? 頁</a></li>
? ? ? ? <li><a href="#">新聞資訊</a></li>
? ? ? ? <li><a href="#">產(chǎn)品展示</a></li>
? ? ? ? <li><a href="#">售后服務(wù)</a></li>
? ? ? ? <li><a href="#">聯(lián)系我們</a></li>
</ul>
</body>
</html>
2018-01-01
你在set進(jìn)去寬度那里沒有清除之前的操作,或者你的瀏覽器看看支不支持這個方法