以下是代码
function messagefadein(){
var oalert=document.getElementById('alert_');
clearInterval(msg_time);
oalert.style.width="40px";
oalert.style.height="30px";
var speed=40;
var speed2=30;
msg_time=setInterval(function(){
speed+=40;
speed2+=30;
if(oalert.offsetWidth>400){
clearInterval(msg_time);
}
else{
oalert.style.left=oalert.offsetLeft+10+"px";
oalert.style.top=oalert.offsetTop+10+"px";
oalert.style.width=oalert.offsetWidth+speed+"px";
oalert.style.height=oalert.offsetHeight+speed2+"px"
}
},30);
oalert.style.display="block";
}
这段代码运行完,总是从左上角扩大,然后往左上方移动几个PX;丝毫没有头绪,请问要怎么改写呢?万分感谢!!
PHP中文网2017-04-10 17:09:38
之所以从左上角放大,是因为这个p的位置并没有移动。之所以向左上角移动了几个像素,是因为你的offsetTop和offsetLeft等于10。