我的跟老师写的一样,但是没有变大的效果,怎么回事?
<style>
* { margin:0px; padding:0px;}
.top { width:200px; overflow:hidden; float:left;}
.top ul {width:200px; overflow:hidden; float:left; }
.top ul li { width:200px; height:100px; background:#ffd800; float:left; margin-bottom:20px;}
</style>
<script>
window.onload = function () {
var count = document.getElementsByTagName("li");
for (var i = 0; i < count.length; i++) {
count[i].onmouseover = function () {
startMove(this, 400);
}
count[i].onmouseout = function () {
startMove(this, 200);
}
}
}
var time = null;
function startMove(obj, end) {
clearInterval(time);
time = setInterval(function () {
var speed = (end - obj.offsetWidth) / 8;
speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
if (obj.offsetWidth == end) {
clearInterval(time);
} else {
obj.style.width = obj.offsetWidth + speed + 'px';
}
}, 30)
}
</script>
<body>
<div class="top" id="top">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
哪位小伙伴能帮我看看,非常感谢