第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Bug為什么width不能到達鼠標(biāo)事件所設(shè)置的值?

Bug為什么width不能到達鼠標(biāo)事件所設(shè)置的值?

甫里 2016-04-18 18:50:14
window.onload=Move; function?getStyle(obj,attr){ if?(obj.currentStyle)?{ return?obj.currentStyle; }else{ return?getComputedStyle(obj,false)[attr]; } } function?Move(){ var?box=document.getElementById("Box"), box2=document.getElementById("Box2"), box3=document.getElementById("Box3") box.onmouseover=function(){ MoveModelFn(this,{"width":600}); } box.onmouseout=function(){ MoveModelFn(this,{"width":400}); } box2.onmouseover=function(){ MoveModelFn(this,{"opacity":100,"width":600}); } box2.onmouseout=function(){ MoveModelFn(this,{"opacity":30,"width":400}); } /*box3.onmouseover=function(){ var?_this=this; MoveModelFn(_this,{"height":300},function(){ MoveModelFn(_this,{'width':600}) }); } box3.onmouseout=function(){ var?_this=this; MoveModelFn(_this,{"height":200}); }*/ } //function?MoveModelFn(obj,{attr:iTarget},fn) function?MoveModelFn(obj,json,fn){ clearInterval(obj.timer); obj.timer=setInterval(function(){ var?flag=true; for(var?attr?in?json){ //獲取屬性值 var?icur=0; if?(attr?==?'opacity')?{ icur?=Math.round(parseFloat(getStyle(obj,attr))*100); }else{ icur=parseInt(getStyle(obj,attr)); } //設(shè)置速度 var?speed=(json[attr]-icur)/10; var?speed=speed>0?Math.ceil(speed):Math.floor(speed); //?判斷停止 if(icur?!=?json[attr]){ flag=false; } if?(attr?==?'opacity')?{ obj.style.filter='alpha(opacity:'+(icur+speed)+')';//icur原始值+變化值speed console.log(obj.style.filter); obj.style.opacity=(icur+speed)/100; }else{ obj.style[attr]=icur+speed+"px"; console.log(obj.style[attr]); } if(flag){ clearInterval(obj.timer); //?回調(diào)函數(shù) if(fn)?{ fn(); } } } },30) } body{ margin:?0; padding:?0; } div{ height:?200px; width:?400px; background:?yellow; border:2px?solid?green; margin-bottom:?10px; filter:?alpha(opacity:30); opacity:?0.3; }<!DOCTYPE?html> <html> <head> <meta?charset="UTF-8"> <title>MoveModel</title> <link?rel="stylesheet"?type="text/css"?href="style/MoveModelCss.css"> </head> <body> <div?id="Box"></div> <div?id="Box2"></div> <div?id="Box3"></div> <script?src="js/MoveModelJs.js"></script> </body> </html>
查看完整描述

1 回答

?
不知名的前端程序猴

TA貢獻32條經(jīng)驗 獲得超22個贊

JS 51行 ??var speed=(json[attr]-icur)/10;?

你的變化速度是除以10,那么當(dāng)json[attr]-icur的值小于10的時候,結(jié)果是0,所以當(dāng)還有幾個像素的時候就不動了。具體怎么調(diào)就看你了。

查看完整回答
反對 回復(fù) 2016-04-19
  • 1 回答
  • 0 關(guān)注
  • 1361 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號