What I am trying to create:
+--------------+
| 20px margin |
| +--------+ |
| | | |
| | Faux | |
| | | |
| +--------+ |
| |
+--------------+
The outer square is the browser viewport. I need to create a webpage that stretches to the bottom even if there is no content, but the page should be surrounded by a 20px margin:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>
* { margin: 0; padding: 0; }
html, body { height: 100%; background: #ccc; }
body { margin: 20px; }
#wrapper { width: 100%; background: #fff; min-height: 100%; }
#header { height: 80px; }
#faux { height: 100%; }
</style>
</head>
<body>
<div id="wrapper">
<div id="header">Header</div>
<div id="faux">Faux</div>
</div>
</body>
</html>
However, this code gives me a vertical scrollbar. This is probably due to IE 10 calculating the height as 100% + 20px
but I need it to be 100% - 20px
, so that there is no scrollbar is the content of the page does not exceed the browser viewport. I have tried a negative margin of 20px on #wrapper
but this did not work.
How can I get rid of the vertical scrollbar?
BTW: I am indifferent of the way the page is built at this stage. #header
is now outside of #faux
but if it makes more sense to place it inside #faux
(or if it necessary for the design to work) then please rearrange the divs :-)
Any help is greatly appreciated!