我的淡入淡出所有不透明因为它变得透明

时间:2010-06-11 19:11:55

标签: javascript css scriptaculous

所以,我试图淡入一个透明的div,有点像hulu当你点击昏暗的灯光时...这就是我所拥有的:

  //show the bg
  new Effect.Appear('darkBackgroundLayer', {duration: 0.3});

然后我的弹出窗口被初始化

// create the div for background dimming


 if($('darkBackgroundLayer')){
   Element.remove('darkBackgroundLayer')
  }

  var transparentBG = document.createElement('div');
  transparentBG.className = 'darkenBackground';
  transparentBG.id = "darkBackgroundLayer"
  transparentBG.style.display = "none";
document.body.appendChild(transparentBG);

和新div的CSS

.darkenBackground {
 background-color: rgb(0, 0, 0);
 opacity: 0.7; /* Safari, Opera */
 -moz-opacity:0.70; /* FireFox */
 filter: alpha(opacity=70); /* IE */
 z-index: 20;
 height: 100%;
 width: 100%;
 background-repeat:repeat;
 position:fixed;
 top: 0px;
 left: 0px;
    }

但是,目前,它逐渐消失......一直到坚实的背部,然后跳到.7不透明......

想法?

1 个答案:

答案 0 :(得分:0)

通过改变Effect.Appear to

来解决
//show the bg
    new Effect.Appear('darkBackgroundLayer', {duration: 0.3,from: 0,to: 0.7});