本人是个初学者,主要问题是这样的,网页上有一个div,我现在通过他的margin-top属性控制它的移动,移动已经实现了,主要是想实现在移动中的动态效果,而不是生硬的转换,感谢各位了……
实现移动的大概代码如下:
function turnPre(id,length)
{
if (parseInt(document.getElementById(id).style.marginTop)==0)
{
return;
}
else
{
document.getElementById(id).style.marginTop = parseInt(document.getElementById(id).style.marginTop) + length;
}
}
实现移动的大概代码如下:
function turnPre(id,length)
{
if (parseInt(document.getElementById(id).style.marginTop)==0)
{
return;
}
else
{
document.getElementById(id).style.marginTop = parseInt(document.getElementById(id).style.marginTop) + length;
}
}
{
if (parseInt(document.getElementById(id).style.marginTop)==0)
{
return;
}
else
{
document.getElementById(id).style.marginTop = parseInt(document.getElementById(id).style.marginTop) + length;
}
}
function turnAni(id,length){
var stepTop=1;//每次位移量
var stepTime=100;//间隔毫秒
for(int i=stepTop;i<length;i=i+stepTop){
setTimeout("turnPre('"+id+"',"+i+")",stepTime);
}
}
var stepTop=1;//每次位移量
var stepTime=100;//间隔毫秒
for(var i=stepTop;i<length;i=i+stepTop){
setTimeout("turnPre('"+id+"',"+stepTop+")",stepTime);
}
}