3
$("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?

1
  • What is the background color? opacity refers to the transparency of something. 1 is completely opaque, meaning no transparency, and 0 is completely transparent, meaning you'll see whatever is in the background - if you have a white background it will get "whiter" and if you have a black background it will get "blacker" Commented Jul 6, 2011 at 3:47

1 Answer 1

5

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.