最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

為什么我的offsetLeft每次加9px

<!doctype>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<title>透明度動(dòng)畫(huà)</title>

<style type="text/css">

#wrap{width:230px;height:105px;position: relative;left:-217px;}

#red{width:200px;height:100px;background-color: red;position: absolute;}

#blue{width:30px;height:30px;background-color: blue;margin-left: 200px;position: absolute;}

</style>

<script type="text/javascript">

window.onload=function(){

var wrap=document.getElementById("wrap");

var timer=null

wrap.onmouseover=function(){

startMove();

}

}


function startMove(){

timer=setInterval(function(){?


if(wrap.offsetLeft==0){

clearInterval(timer);

}

else{


wrap.style.left=wrap.offsetLeft+1+'px'; //console.log(wrap.offsetLeft);

}

},300);

}

</script>

</head>

<body>

<div id="wrap">

<div id="red"></div>

<div id="blue"></div> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

</div>

</body>

</html>

為什么我的offsetLeft每次加9px

正在回答

1 回答

因?yàn)閣rap獲取的offsetLeft不是217 ?而是209

他把body的margin也算進(jìn)去了

修改辦法:

在樣式里添加: ?*{ padding:0; margin:0}

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
JS動(dòng)畫(huà)效果
  • 參與學(xué)習(xí)       113911    人
  • 解答問(wèn)題       1502    個(gè)

通過(guò)本課程JS動(dòng)畫(huà)的學(xué)習(xí),從簡(jiǎn)單動(dòng)畫(huà)開(kāi)始,逐步深入各種動(dòng)畫(huà)框架封裝

進(jìn)入課程

為什么我的offsetLeft每次加9px

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)