<script type="text/javascript">window.onload = function(){ var content = document.getElementsByClassName('content')[0]; var A = document.getElementsByTagName('a'); for(var i = 0; i<A.length; i++){ A[i].onmouseenter = function(){ var _this = this.getElementsByTagName('i')[0]; move(_this,{top:-25,opacity:0},function(){ _this.style.top=35 + 'px'; move(_this,{top:20,opacity:100}); }); } } } function move(obj,json,fu){ clearInterval(obj.time); obj.time = setInterval(function(){ for(var attr in json){ var flag = true; var icur = 0; if(attr == 'opacity'){ icur = Math.round(parseFloat(getStyle(obj,attr))*100); }else{ icur = parseInt(getStyle(obj,attr)); } var speed = 0; speed = (json[attr] - icur)/8; speed=speed>0?Math.ceil(speed):Math.floor(speed); if(icur != json[attr]){ flag = false; } if(attr == 'opacity'){ obj.style[attr] = (icur + speed)/100; obj.style.filter='alpha(opacity:'+(icur+speed)+')'; }else{ obj.style[attr] = icur + speed + 'px'; } if(flag){ clearInterval(obj.time); if(fu){ fu(); } } } },10); } function getStyle(obj,attr){? ?if(obj.currentStyle){? ? return obj.currentStyle[attr];? ?}else{? ? return getComputedStyle(obj,false)[attr];? ?}}</script>
透明值不為整值1,而是0.83。我找不原因
情積雪
2016-05-22 23:12:04