第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

為什么我的offsetLeft每次加9px

<!doctype>

<html>

<head>

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

<title>透明度動畫</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ù)我~

舉報

0/150
提交
取消

為什么我的offsetLeft每次加9px

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

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

幫助反饋 APP下載

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

公眾號

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