Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make <body> fill entire screen?

I'm using a radial gradient as the background on my webpage, like so:

background-image: -webkit-gradient(radial, 100% 100%, 10, 90% 90%, 600, from(#ccc), to(#000));

It works, but when the content does not fill the whole page the gradient is cut off. How can I make the <body> element fill the entire page, always?

like image 939
Ry- Avatar asked Oct 10 '22 13:10

Ry-


People also ask

How do you make your body take up the whole page?

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.


2 Answers

html, body {
    margin: 0;
    height: 100%;
}
like image 251
capdragon Avatar answered Oct 13 '22 03:10

capdragon


On our site we have pages where the content is static, and pages where it is loaded in with AJAX. On one page (a search page), there were cases when the AJAX results would more than fill the page, and cases where it would return no results. In order for the background image to fill the page in all cases we had to apply the following CSS:

html {
   margin: 0px;
   height: 100%;
   width: 100%;
}

body {
   margin: 0px;
   min-height: 100%;
   width: 100%;
}

height for the html and min-height for the body.

like image 33
jwatts1980 Avatar answered Oct 13 '22 03:10

jwatts1980