<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>relative样式</title><style type="text/css">*{margin:0;padding:0;}#div1{ width:200px; height:200px; background:red; position:relative; left:-200px; top:0px;}#share{ width:50px; height:100px; background:blue; position:absolute; left:200px; top:50px;} </style><script type="text/javascript">window.onload=function(){ var oDiv=document.getElementById("div1") oDiv.onmouseover=function(){ startMove() }}var timer=nullfunction startMove(){var oDiv=document.getElementById("div1") timer=setInterval(function(){ if(oDiv.offsetLeft==0){ clearInterval(timer) } else{ oDiv.style.left=oDiv.offsetLeft+10+'px'} },30)}</script></head><body> <div id="div1"><span id="share">move</span></div></body></html>
添加回答
举报
0/150
提交
取消