我有這樣的DIV設置。如何按像素移動DIV像素
<div id="parent" class="parent">
<div id="child" class="child">
</div>
</div>
樣式
<style>
.parent{
float:left; height:300; width:300px; background-color:#00ff00;
}
.child{
float:left; height:60; width:60px; background-color:#00ff00;
}
</style>
<script>
function move(){
while(m < 100){
document.getElementByid('child').style.marginTop = m;
m = m+1;
}
}
move();
</script>
我想通過像素從頂部100個像素移動內部DIV(名爲子)像素底部。 我認爲它可以使用style.marginTop =「」和的setTimeout()函數
但依然沒能得到這個工作完成。
向我們展示你的JavaScript代碼。 – Halcyon 2013-03-01 16:40:25
你是指動畫嗎? – Dogoku 2013-03-01 16:40:30
@dogoku是動畫。 – 2013-03-01 16:41:27