透明值不为整值1,而是0.83。我找不原因

<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>

http://img.mukewang.com/5743f77a0001ca3705240412.jpg

情积雪
浏览 1227回答 1
1回答

一杯2块的奶茶

html代码呢
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript