<!DOCTYPE?html>
<html>
<head>
????<meta?charset="utf-8">
????<title></title>
????<link?rel="stylesheet"?type="text/css"?href="css/1.css">
????<style?type="text/css">????????
????????*{margin:0;padding:0;}
????????li{
??????????list-style:none;
????????}
????????.huiyuan,.mima?,.chongfu{
?????????????width:500px;?
?????????????font-size:?30px;?
?????????????margin:0?auto;
????????}
????????#yu{
????????????position:relative;
????????????top:0px;
????????????left:-480px;
????????????border:?2px?solid?#000;
????????????border-radius:?10px;
????????????width:500px;
????????}
</style>
</head>
<body>
<!--?<form?method="post"?action="saike.php">?-->
<div?id="yu">?
????<ul>
????????<li?class="huiyuan">會員:<input?type="text"??placeholder="ttt"/></li>
????????<li??class="mima">密碼:<input?type=?"password"/></li>
????????<li?class="chongfu">重復密碼:<input?type="password"/></li><input?type="button"?name="bbb"?onclick="aaa()"?value="333">
????</ul>
</div>
<!--?</form>?-->
<script>
window.onload?=?function(){
????var?c?=?document.getElementById('yu');
????c.onmouseover?=function(){
????????move();
????????}
????c.onmouseout?=?function(){
????????leave();
????????}???
}??
var?timer?=?null;??????
function?move(){????
????????clearInterval(timer);
????????timer?=?setInterval(function(){????????
????????var?c?=?document.getElementById('yu');
????????if(c.offsetLeft?>=?0){
????????????clearInterval(timer);
????????}
????????else{????
????????????c.style.left?=?c.offsetLeft+10+"px";
????????}
????},10)
}
function?leave(){????
????????clearInterval(timer);
????????timer?=?setInterval(function(){????????
????????var?c?=?document.getElementById('yu');
????????if(c.offsetLeft?<=?-480+"px"){
????????????clearInterval(timer);
????????}
????????else{????
????????????c.style.left?=?c.offsetLeft-10+"px";
????????}
????},10)
}????
</script>
</body>
</html>
2016-08-20
offsetLeft 為數(shù)值 ?不該+px
function leave(){ ? ?
? ? ? ? clearInterval(timer);
? ? ? ? timer = setInterval(function(){ ? ? ? ?
? ? ? ? var c = document.getElementById('yu');
? ? ? ? if(c.offsetLeft <= -480){
? ? ? ? ? ? clearInterval(timer);
? ? ? ? }
? ? ? ? else{ ? ?
? ? ? ? ? ? c.style.left = c.offsetLeft-10+"px";
? ? ? ? }
? ? },10)
} ? ?