I am trying to use the following sticky footer solution from http://ryanfait.com/sticky-footer/
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -4em;
}
.footer, .push {
height: 4em;
}
h1 {
margin-top:1em;
}
<html>
<head>
<link rel="stylesheet" href="layout.css" ... />
</head>
<body>
<div class="wrapper">
<h1>This header screws with sticky footer</h1>
<p>Your website content here.</p>
<div class="push"></div>
</div>
<div class="footer">
<p>Copyright (c) 2008</p>
</div>
</body>
</html>
However, as the above snippet demonstrates adding a margin to the <h1> tag results in an undesired scrollbar.
From my basic understanding, the margin should affect only the size of the <h1> tag, which should not affect the size/position of the wrapper (unless there is no space - but clearly there is plenty of space).
EDIT: I am not trying to find a solution, I want to understand what happens. It appears that the margin does not push the <h1> tag down relative to the parent container, but instead it pushes the parent container down together with the <h1> tag. Is this correct, and if yes, why? It seems fairly counter-intuitive.
tag affects the .wrapper container.
– cornergraf Jan 22 '15 at 09:57