views:

110

answers:

2

How do I use javascript to black out all content except a single html element?

This is Chrome-specific app so CSS3 can be used.

A: 

You could iterate through all the elements of a document and set their background color to black, except the one with a certain ID.

You don't need CSS3 for this at all.

Andrew Johnson
I can set the back and foreground color to black but what about images, other content?
gAMBOOKa
Set visibility:hidden
Andrew Johnson
+3  A: 

Use one <div> with position: fixed; that covers the page, with something like background-color: rgba(0, 0, 0, .5);, then simply place the element you wish to show on top of that.

nlogax
How do I manage the order of placement. Z-index i mean?
gAMBOOKa
Just give the overlay div a z-index higher than your other stuff, and the content element a higher index than that one. :)#overlay { z-index: 100; } #dialog { z-index: 110; }
nlogax