I’m trying to offset a body tag by some padding. However, I’d like to have the body adjusted so that it doesn’t cause it to fall below the browser window and induce scrollbars.
Here is an example of what I’m trying to accomplish: http://jsfiddle.net/jM9Np/1/
HTML:
<body> </body>
CSS:
html, body {
height: 100%;
}
body {
margin-top: 20em;
background-color: LemonChiffon;
}
Ideally I’d like to subtract 20em from the body’s height. Is there anyway to do this without any Javascript and in a manner that is supported by all browsers (with exception of Internet Explorer)? Thanks.
It depends. You can use borders, f.ex:
http://jsfiddle.net/jM9Np/10/
But the best way IMHO would be to add another DIV inside the body and position it absolute:
http://jsfiddle.net/za4e3/