I\'m kind of new to positioning divs how I want them in a website, so I hope someone can help here. What I\'m trying to get is a sandwich-type set up with a scrolling content i
Simply set the height of the consecutive elements to equal 100% and set your content DIV to scroll on the Y-axis:
Sandwich Layout
html,
body { height: 100%; margin: 0; padding: 0; } /* This is important */
header,
footer { background: #ccc; height:20%; }
#main { height: 60%; overflow-y:scroll; }
Fiddle: http://jsfiddle.net/kboucher/3E8Gg/
2020 UPDATE:
HTML:
Sandwich Layout
Content here
CSS:
body,
html {
height: 100vh;
overflow: hidden;
margin: 0;
padding: 0;
}
body {
display: flex;
flex-direction: column;
}
header,
footer {
background: #eee;
padding: 1rem;
}
.main {
flex: 1 0 auto;
height: 0; // prevents flex box expanding out of view-height
overflow-y: auto;
padding: 1rem;
.fake-height {
height: 1000px;
}
}
https://codepen.io/kboucher/pen/dyomxWN