為什么div的大小不能還原成200/200,請幫忙看下,TKS~!
<!DOCTYPE html>
<html>
?? ?<head>
?? ??? ?<meta charset="UTF-8">
?? ??? ?<title>運動框架檢驗03</title>
?? ??? ?<style type="text/css">
?? ??? ??? ?*{margin: 0;padding: 0;list-style: none;}
?? ??? ??? ?div{
?? ??? ??? ??? ?width: 200px;
?? ??? ??? ??? ?height: 200px;
?? ??? ??? ??? ?border: 30px solid red;
?? ??? ??? ??? ?background: blue;
?? ??? ??? ??? ?margin: 50px auto;
?? ??? ??? ??? ?opacity: 1;
?? ??? ??? ?}
?? ??? ?</style>
?? ??? ?
?? ??? ?<script type="text/javascript" src="js/starMove.js"></script>
?? ??? ?<script type="text/javascript">
?? ??? ??? ?window.onload=function(){
?? ??? ??? ??? ?var odiv=document.getElementById("div");
?? ??? ??? ??? ?odiv.onmouseover=function(){
?? ??? ??? ??? ??? ?starMove(odiv,{width:400,height:400,opacity:0},function(){
?? ??? ??? ??? ??? ??? ?odiv.style.background="green";
?? ??? ??? ??? ??? ??? ?starMove(odiv,{width:200,height:200,opacity:100});
?? ??? ??? ??? ??? ?});
?? ??? ??? ??? ?};
?? ??? ??? ?};
?? ??? ?</script>
?? ?</head>
?? ?<body>
?? ??? ?<div id="div"></div>
?? ?</body>
</html>
2016-11-13
function?startMove(obj,json,fn){ ????clearInterval(obj.timer); ????obj.timer?=?setInterval(function(){ ????????var?flag?=?true; ????????for(var?attr?in?json){ ????????????var?typeValue?=?null; ????????????if(attr=="opacity") ????????????????typeValue?=?Math.round(parseFloat(getStyle(obj,attr))*100); ????????????else ????????????????typeValue?=?parseInt(getStyle(obj,attr)); ????????????var?speed?=?(json[attr]-typeValue)/8; ????????????speed?=?speed>0??Math.ceil(speed):Math.floor(speed); ????????????if(typeValue!=json[attr]){ ????????????????console.info(flag) ????????????????flag?=?false; ????????????} ????????????if(attr=="opacity"){ ????????????????obj.style.filter?=?'alpha(opacity:'+typeValue+speed+')'; ????????????????obj.style[attr]?=?(typeValue+speed)/100; ????????????} ????????????else ????????????????obj.style[attr]?=?typeValue+speed+"px"; ????????} ????????if(flag){ ????????????console.info("flag:"+flag); ????????????clearInterval(obj.timer); ????????????if(fn){ ????????????????fn(); ????????????} ????????} ????},30); }這是我的移動函數,是可以實現你的效果
2016-11-12
是不是你的運動函數的問題,還有opcity:100對的嗎,按照課程里封裝的函數不應該是opcity:1才是不透明嗎
2016-11-10
不是啊,先是200/200,變成400/400,完成后再變成200/200,跟移入移出沒有關系吧,是鏈式運動,完成變大變小的~~
2016-11-09
以為你沒有寫移出的操作啊。只寫了onmouseover你的onmouseout呢