0

I have a html page with different elements and I want to add a div with a kind of transparent effect to hide the content of my page. I tried to wrap my whole page in a div just after the body with the following css

<body> <div style="position:relative;width:100%;height:100%; background-color:red;z-index:9999999"> </div> </body>

Can anyone help?

Quantico
  • 2,398
  • 7
  • 35
  • 59
skunk a
  • 235
  • 1
  • 2
  • 10

2 Answers2

0

change position:relative to position:fixed or position:absolute and add:

 top:0;
 left:0;
 bottom:0;
 right:0;
scooterlord
  • 15,124
  • 11
  • 49
  • 68
0

Something like this ?

#modal{width:100%;height:100%;position:absolute;top:0px;left:0px;z-index:1000;background-color:grey;opacity:.8;display:none;}
<div id="modal">modal window<button onclick="document.getElementById('modal').style.display='none'">Close</button></div>
<div id ="Mainwindow">content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content </div><button onclick="document.getElementById('modal').style.display='block'">Display modal</button>
Billy
  • 2,448
  • 1
  • 10
  • 13
  • Shouldn't use opacity, since it's going to make the inner divs of that overlay div transparent as well. –  Nov 17 '14 at 19:33
  • There isn't any inner divs. I was only using it to show the effect anyway , opacity wasn't needed – Billy Nov 17 '14 at 19:38