At the beginning everything is working fine. I have the middle element and the footer. And it is the way I want it. But when I resize the window, the footer gets behind the main element. Here is the code. How would I work about to make the footer stick (it is not a fixed positioning) at the bottom?
body{
height: 100%;
width: 100%;
}
.mainContent{
width: 200px;
height: 100px;
border: 1px solid #222;
margin-top: -50px;
margin-left: -100px;
position: absolute;
top: 50%;
left: 50%;
}
.footer{
height: 20px;
background: #444;
position: absolute;
bottom: 0;
width: 100%;
left: 0;
}
HTML
<html>
<head></head>
<body>
<div class="mainContent"></div>
<div class="footer"></div>
</body>
</html>