Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML overlay height to cover entire visible page

I have a web page that loads some stuff using AJAX. I want to display an overlay with a loading indicator while the loading is in progress, so that the user cannot interact with most of the page - except the menu at the top. I'm using jQuery and the jQuery BlockUI plugin to do this.

I call $(element).block() and it works fine, but the overlay only extends as far down as the current content of my page. As more content is loaded and added to the page the overlay moves down with it and this looks a bit ugly. Ideally I'd like it to cover the entire visible area of the page right from the start. A simple hack for doing this would be to set a large height value for the overlay, like this:

$(myElement).block({
        overlayCSS: {
            height: '10000px'
        }
 });

... but this creates a scrollbar! How do I avoid this and make it just the right height to cover the visible page, but not enlarge it?

like image 950
EMP Avatar asked Mar 29 '10 01:03

EMP


People also ask

How do I cover an entire page in HTML?

If you set the width to 100% on the body element you will have a full page width. This is essentially equivalent to not setting a width value and allowing the default. If you want to use the body element as a smaller container and let the HTML element fill the page, you could set a max-width value on the body.

How do you make a page fill the whole screen?

You can make Start full screen and see everything in one view. Select Start , then select Settings > Personalization . Select Start , and then turn on Use Start full screen.

How do I cover a full page in a div?

You can also use position absolute as well as set all the viewport sides (top, right, bottom, left) to 0px will make the div take the full screen.


2 Answers

Use position: fixed; instead of position: absolute. This way the overlay will not move even if you scroll.

like image 71
caruzko Avatar answered Sep 18 '22 15:09

caruzko


In XHTML the html and body elements are not quite as magical as in HTML. The body element doesn't fill the viewport (window) automatically, it's size is only as tall as it's contents.

To make an element fill the window you first have to make the html and body elements fill the window:

html, body { height: 100%; }

Then you can use height: 100%; on an element in the body to make it cover the full height.

like image 29
Guffa Avatar answered Sep 20 '22 15:09

Guffa