Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a div 80% the size of the page?

Tags:

html

css

I'd like to make a page container div have a top margin of 10% and bottom margin of 10%. How can I make the div take the remaining 80% of the page, all the time ( no matter if it has content or not )?

like image 449
Geo Avatar asked Dec 03 '22 03:12

Geo


2 Answers

This should work:

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            div { 
                position: absolute;
                height: 80%; 
                width: 80%; 
                top: 10%; 
                left: 10%; 
                background-color: #FFCC00; 
            }
        </style>
    </head>
    <body>
        <div>
            This should prove my point.
        </div>
    </body>
</html>
like image 89
tdammers Avatar answered Dec 07 '22 23:12

tdammers


You can try:

CSS
---
.container {
   margin-top:10%;
   margin-bottom:10%;
   height:80%;
}

<div class="container"></div>
like image 33
OV Web Solutions Avatar answered Dec 07 '22 23:12

OV Web Solutions