开发者

Jquery setting opacity issue

开发者 https://www.devze.com 2023-03-18 11:37 出处:网络
$(\"html\").fadeTo(\"slow\",0.5); OR $(\"html\").css({ \'opacity\':\'0.5\' }); Why does either of these scripts whiten the page? I need it to become darker, no whiter, and usually that\'s what opa
$("html").fadeTo("slow",0.5); 
OR 
$("html").css({ 'opacity':'0.5' });

Why does either of these scripts whiten the page? I need it to become darker, no whiter, and usually that's what opacity doe开发者_Python百科s but not here...

How can I set a black opacity to my html with jquery?


Add a black div and fade it in on top of everything

HTML:

<body>
    <div id="cover"></div>
</body>

CSS:

#cover {
    height:100%;
    width:100%;
    background-color:#000;
    display:none;
    position:absolute;
    top:0;
    left:0;
    z-index:99999999;
}

JQuery:

$('#cover').fadeTo("slow",0.5);

Here's a working example: http://jsfiddle.net/AlienWebguy/GM2Z6/2/

0

精彩评论

暂无评论...
验证码 换一张
取 消