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

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

為什么透明度變1后會閃爍,chrome上測試的,哪位大神幫幫忙

為什么透明度變1后會閃爍,chrome上測試的,哪位大神幫幫忙

慕標3810760 2016-05-20 23:30:53
<!DOCTYPE HTML><html><head><style type="text/css">.logo_right{float:right;margin-top:280px;margin-right:40px;opacity:0.6;}.logo_right form{background-color:#F00;height:30px;-webkit-border-radius:7px;padding-top:6px;}.search-text{border:none;height:21px;width:270px;font-size:16px;outline:none;margin-left:6px;float:left;}.search-button{border:0;background:url(../images/search.jpg) no-repeat;width:25px;height:21px;margin-right:6px;float:left;outline:none;}</style></head><body bgcolor="black">? ? <div class="logo_right" id="logo_right">? ? ? ? <form><input type="text" class="search-text" name="search-text" onfocus="startAlpha(0.8)" onblur="startAlpha(0.6)"/><input type="submit" class="search-button" value=""/></form>? ? ? ? </div> ?</body></html><script>var timer3=null;var alpha2=0.6;function startAlpha(target){clearInterval(timer3);var searchText=document.getElementById("logo_right");timer3=setInterval(function(){var speed=0;if(alpha2<target){speed=0.1}else{speed=-0.1}if(alpha2==target){clearInterval(timer3);timer3=null;}else{alpha2+=speed;searchText.style.opacity=alpha2;}},30)}</script>
查看完整描述

3 回答

已采納
?
Wo可能不是我

TA貢獻2條經驗 獲得超0個贊

去看看Js浮點數精度問題,0.7+0.1不等于0.8,所以程序進入了死循環才會一直閃

查看完整回答
反對 回復 2016-05-23
?
慕標3810760

TA貢獻1條經驗 獲得超0個贊

謝謝大神,很有幫助??!

查看完整回答
反對 回復 2016-05-23
?
一杯2塊的奶茶

TA貢獻226條經驗 獲得超75個贊


你判斷速度的地方,只有加減兩種,程序進入后它會不停的加減加減,所以會出現不停的閃爍,你在最后的else里面輸出一個數,會發現他一直在輸出,

查看完整回答
反對 回復 2016-05-23
  • 3 回答
  • 0 關注
  • 1513 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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