Forum Moderators: open

Message Too Old, No Replies

How do I 'div over' an entire page?

         

physics

3:20 am on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to make a div go from having zero size to filling up the entire page, covering everything else, with a graphic (or whatever) centered in it. I've seen this somewhere but can't remember where. Any tips?

Trace

1:56 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



If I understand you correctly and you want to cover the entire page, then just add this at the bottom of your html;

<div style="position:absolute; top:0px; left:0px; width:100%; height:100%; background-color:red;">Something here</div>

Little_G

2:18 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



Hi,

I'd use:

<div id="cover" style="position:absolute; top:0; left:0; right:0; bottom:0; background-color:red; z-index:99;"><img src=""></div>

I find sometimes height:100%; makes the scrollbar appear.
Plus the z-index should make sure that nothing appears on top.

You can make it appear/disappear using document.getElementById('cover').style.display='block' / document.getElementById('cover').style.display='none' respectively.

Andrew

Dabrowski

6:24 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have used Little_G's solution when I needed popups (relevant to the site) to get around the new popup blocking things.