JSFiddle - React, Tailwind, and code Playground
by fritzdenim
HTML
<div class="container">
<div class="header">
Header goes here.
</div>
<div class="content">
Content goes here.
</div>
<div class="footer">
Footer goes here.
</div>
</div>
CSS
html, body {
padding: 0px; /* add */
margin: 0px; /* add */
}
.container {
margin: 0px;
background-color: #ddd;
border: 1px solid blue;
height: 100%;
}
.header {
float: left;
clear: both;
background-color: #999;
border: solid 1px #000000;
height: 40px; /* decide fixed height */
width: 100%;
}
.content {
float: left;
clear: both;
padding: 0em 0em 2em; /* bottom padding for footer */
overflow-y: auto;
background-color: #dfdfdf;
border: 1px solid red;
height: 500px; /* decide the fixed height or change with jquery */
min-height: 100px; /* decide the fixed height or change with jquery */
width: 100%;
}
.footer {
height: 30px; /* decide fixed height */
float: left;
clear: both;
width: 100%;
border: 1px solid #000;
background-color: #afafaf;
bottom: 0; /* stick to bottom */
}
JavaScript
$(document).ready(resizeContent);
$(window).resize(resizeContent);
function resizeContent() {
var containerHeight = $(".container").outerHeight();
var headerHeight = $(".header").outerHeight();
var footerHeight = $(".footer").outerHeight();
$(".content").height(containerHeight-headerHeight-footerHeight-37 + "px");
}
// If IE, no need to deduct 37