亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

為什么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>


正在回答

4 回答

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);
}

這是我的移動函數,是可以實現你的效果

0 回復 有任何疑惑可以回復我~

是不是你的運動函數的問題,還有opcity:100對的嗎,按照課程里封裝的函數不應該是opcity:1才是不透明嗎

0 回復 有任何疑惑可以回復我~

不是啊,先是200/200,變成400/400,完成后再變成200/200,跟移入移出沒有關系吧,是鏈式運動,完成變大變小的~~


0 回復 有任何疑惑可以回復我~

以為你沒有寫移出的操作啊。只寫了onmouseover你的onmouseout呢

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么div的大小不能還原成200/200,請幫忙看下,TKS~!

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號