The html structure I'm working with is as follows...
<div class="header"></div>
<div class="main"></div>
<div class="footer"></div>
Accompanied by the following css styling...
.header{
position: fixed;
background-color: #f00;
height: 100px;
}
.main{
background-color: #ff0;
height: 700px;
}
.footer{
position: fixed;
bottom: 0;
background-color: #f0f;
height: 120px;}
I am facing an issue where the header and footer do not remain fixed in their positions. My intention is for only the "main" section to be scrollable, with the "header" and "footer" remaining fixed. What might I have overlooked? How can I achieve this desired layout?
+-------------------------------------+
| header | -> at fixed position (top of window)
+-------------------------------------+
| main |
| |
| | -> scrollable content
| | scrollbar belongs to the window, not main
| |
| |
+-------------------------------------+
| footer | -> at fixed position (bottom of window)
+-------------------------------------+
To see a live example, view this fiddle