Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I want to know if and how I can make the body element a fixed size. For example, in this case for my webpage I gave the HTML and body elements different colors. This way, the body element is green and the HTML is blue. This makes it look like there is a green sheet on the blue background. However, if I have less text on the page, it makes the body element "smaller" as in the green only takes up a small part of the page and the rest of the page is just blue. How can I possibly make it so that the green part (body) extends to the bottom even when there is no text?

What I have tried:

Here is code so far in CSS:

html {
background-color: blue;
}

body {
background-color: green;
border: 3px solid gray;
border-radius: 20px;
}

Now here in html I only have 3 paragraphs:

Example 1........



Example 1........



Example 1........



But now on webpage, it only displays the green body background for the text. Below the text, there is nothing, so the background stays blue. How to extend the body further?

thanks in advance
Posted
Updated 14-Jun-20 2:46am

1 solution

just make your body height vh:100 or 100%

my way is to make body width height 100% with blue and than create content div with Gray border and border-radius
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900