請幫我看看這個問題
它的實際移動距離怎么和設(shè)置的不一樣
<style>
*{margin=0;padding=0;}
div{
position:relative;
left:-200px;
width:200px;
height:100px;
background:#9F6;}
</style>
<script>
window.onload=function(){
var mydiv=document.getElementById('odiv');
? mydiv.onmouseover=function(){
? starmove();}
? mydiv.onmouseout=function(){
? starmove1();} ? ? ?
}
var timer=null;
function starmove(){
clearInterval(timer);
var mydiv=document.getElementById('odiv');
? ? timer=setInterval(function(){
mydiv.style.left=mydiv.offsetLeft+10+'px';}
,300)}
function starmove1(){
clearInterval(timer);
var mydiv=document.getElementById('odiv');
? ? timer=setInterval(function(){
mydiv.style.left=mydiv.offsetLeft-10+'px';}
,300)}
</script>
<body>
<div id="odiv"></div>
</body>
</html>
2015-09-18
position:absolute ?絕對引用