Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery setting opacity issue

$("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 does but not here...

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

like image 938
Adam Strudwick Avatar asked Feb 03 '26 14:02

Adam Strudwick


1 Answers

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/

like image 130
AlienWebguy Avatar answered Feb 06 '26 05:02

AlienWebguy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!