zoukankan      html  css  js  c++  java
  • 20150620图片的透明度渐变

    function fade(obj,tar) {
        obj.timer && clearInterval(obj.timer);
        obj.timer=setInterval(function () {
            var cur=parseInt(css(obj,'opacity')*100);
            var speed=(tar-cur)/7;
            speed=(speed>0)?Math.ceil(speed):Math.floor(speed);
            if(cur!=tar){
                obj.style.opacity=(cur+speed)/100;
                obj.style.filter='alpha(opacity='+(cur+speed)+')'
            }else{
                clearInterval(obj.timer);
                obj.timer=null;    
            }
        },40);
    }
    function css(obj, attr){
        if(obj.currentStyle){
            return obj.currentStyle[attr];
        } else {
            return getComputedStyle(obj, false)[attr];
        }
    }
    var box=document.getElementById('box');
    fade(box,40)
  • 相关阅读:
    Java线程死锁模拟
    Arrays Multi
    PHP Forms
    simple grammer
    有意义的命名 Meaningful names
    整洁代码
    XPath
    多态
    复用类
    访问控制权限
  • 原文地址:https://www.cnblogs.com/wz0107/p/4590199.html
Copyright © 2011-2022 走看看