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

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

功能殘缺,添加opacity時候無法正常添加上,望大俠幫忙修改下,總得來位大俠來拯救小弟吧,慕課的暖風吹過來。。~小弟在此召喚 啊啊啊啊啊啊啊啊啊?。。?!

<!--HTML
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-->
<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<title></title>
????<style>
????????*{
????????????padding:?0;
????????????margin:?0;
????????}
????????#wrap{
????????????width:?200px;
????????????height:?100px;
????????????opacity:1;
????????????filter:?alpha(opacity:100);
????????????background-color:#7affdd;
????????}
????</style>
</head>
<script?src="JS--Animation-10.js"></script>
<body>
????<div?id="wrap"></div>
</body>
</html>

/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
JavaScript
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/**
?*?Created?by?Administrator?on?2016/1/6.
?*/
window.onload=function(){
????var?div?=?document.getElementById('wrap');
????div.onmouseover=function(){
????????setMove(div,{width:500,height:400,opacity:.5});
????}
????div.onmouseout=function(){
????????setMove(div,{width:200,height:100});
????}
}

function?setMove(obj,json,fu){
????var?flas?=true;
????clearInterval(obj.timer);
????obj.timer=setInterval(function(){
????????for(var?sty?in?json){
????????????var?ico?=?0;
????????????if(sty=='opacity'){
????????????????ico?=?Math.random(parseFloat(setTmo(obj,sty))*100);
????????????}else{
????????????????ico?=?parseInt(setTmo(obj,sty));
????????????}
????????????var?speed?=?(json[sty]?-ico)/5;
????????????speed?=?speed>0??Math.ceil(speed):Math.floor(speed);
????????????if(json[sty]?!=ico){
????????????????flas?=false;
????????????}
????????????if(json[sty]=='opacity'){
????????????????obj.style.filter='alpha(opacity'+(ico+speed)+"px";
????????????????obj.style.opacity=(ico+speed)/100;
????????????}else{
????????????????obj.style[sty]=ico+speed+"px";
????????????}
????????????if(flas){
????????????????clearInterval(obj.timer);
????????????????if(fu){
????????????????????fu();
????????????????}
????????????}
????????}
????},30)
}

function?setTmo(obj,attr){
????if(obj.currentStyle){
????????return?obj.currentStyle[attr];
????}else{
????????return?getComputedStyle(obj,false)[attr];
????}
}


正在回答

2 回答

window.onload=function(){
????var?div?=?document.getElementById('wrap');
????div.onmouseover=function(){
????????setMove(div,{width:500,height:400,opacity:50});
????}
????div.onmouseout=function(){
????????setMove(div,{width:200,height:100,opacity:100});
????}
}

function?setMove(obj,json,fu){
????clearInterval(obj.timer);
????obj.timer=setInterval(function(){
????????var?flas?=true;
????????for(var?sty?in?json){
????????????var?ico?=?0;
????????????if(sty=='opacity'){
????????????????ico?=?Math.round(parseFloat(setTmo(obj,sty))*100);
????????????}else{
????????????????ico?=?parseInt(setTmo(obj,sty));
????????????}
????????????var?speed?=?(json[sty]?-ico)/5;
????????????speed?=?speed>0??Math.ceil(speed):Math.floor(speed);
????????????if(json[sty]?!=ico){
????????????????flas?=false;
????????????}
????????????if(sty=='opacity'){
????????????????obj.style.filter='alpha(opacity:'+(ico+speed)+")";
????????????????console.log((ico+speed)/100);
????????????????obj.style.opacity=(ico+speed)/100;
????????????}else{
????????????????obj.style[sty]=ico+speed+"px";
????????????}
????????????if(flas){
????????????????clearInterval(obj.timer);
????????????????if(fu){
????????????????????fu();
????????????????}
????????????}
????????}
????},30);
}

function?setTmo(obj,attr){
????if(obj.currentStyle){
????????return?obj.currentStyle[attr];
????}else{
????????return?getComputedStyle(obj,false)[attr];
????}
}

錯誤太多了,首先你的opacity的取值是(0到100)才對,

然后ico = Math.round(parseFloat(setTmo(obj,sty))*100);你寫成了Math.random,

if(sty=='opacity'){寫成了if(json[sty]=='opacity'){

obj.style.filter='alpha(opacity:'+(ico+speed)+")";寫成了obj.style.filter='alpha(opacity'+(ico+speed)+"px";


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

蛋疼少年的和諧青春 提問者

非常感謝您這么詳細的指出我的錯誤,謝謝您,我以后也會多多注意細節方面。辛苦啦!!嘿嘿 感謝大俠~!?。。?!
2016-01-08 回復 有任何疑惑可以回復我~
<!--HTML
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-->
<!DOCTYPE?html>
<html>
<head>
????<meta?charset="UTF-8">
????<title></title>
????<style?type="text/css">
????????*{
????????????padding:?0;
????????????margin:?0;
????????}
????????#wrap{
????????????width:?200px;
????????????height:?100px;
????????????opacity:1;
????????????filter:?alpha(opacity:100);
????????????background-color:#7affdd;
????????}
????</style>
</head>
<body>
????<div?id="wrap"></div>
</body>

?
<script?type="text/javascript">
window.onload=function(){
????var?div?=?document.getElementById('wrap');
????div.onmouseover=function(){
????????setMove(div,{width:500,height:400,opacity:.5});
????}
????div.onmouseout=function(){
????????setMove(div,{width:200,height:100});
????}
}
?
function?setMove(obj,json,fu){
????var?flas?=true;
????clearInterval(obj.timer);
????obj.timer=setInterval(function(){
????????for(var?sty?in?json){
????????????var?ico?=?0;
????????????if(sty=='opacity'){
????????????????ico?=?Math.random(parseFloat(setTmo(obj,sty))*100);
????????????}else{
????????????????ico?=?parseInt(setTmo(obj,sty));
????????????}
????????????var?speed?=?(json[sty]?-ico)/5;
????????????speed?=?speed>0??Math.ceil(speed):Math.floor(speed);
????????????if(json[sty]?!=ico){
????????????????flas?=false;
????????????}
????????????if(json[sty]=='opacity'){
????????????????obj.style.filter='alpha(opacity'+(ico+speed)+"px";
????????????????obj.style.opacity=(ico+speed)/100;
????????????}else{
????????????????obj.style[sty]=ico+speed+"px";
????????????}
????????????if(flas){
????????????????clearInterval(obj.timer);
????????????????if(fu){
????????????????????fu();
????????????????}
????????????}
????????}
????},30)
}
?
function?setTmo(obj,attr){
????if(obj.currentStyle){
????????return?obj.currentStyle[attr];
????}else{
????????return?getComputedStyle(obj,false)[attr];
????}
}
</script></html>


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

蛋疼少年的和諧青春 提問者

鼠標移動上去后,透明度還是沒有改變呢,大俠。。。。
2016-01-08 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

功能殘缺,添加opacity時候無法正常添加上,望大俠幫忙修改下,總得來位大俠來拯救小弟吧,慕課的暖風吹過來。。~小弟在此召喚 啊啊啊啊啊啊啊啊啊啊?。?!

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

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

幫助反饋 APP下載

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

公眾號

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