Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
Last active December 10, 2015 12:08
Show Gist options
  • Select an option

  • Save jehoshua02/4432293 to your computer and use it in GitHub Desktop.

Select an option

Save jehoshua02/4432293 to your computer and use it in GitHub Desktop.
After hours of beating my head against the wall, I finally got my cake and ate it too. I wanted a) sticky footer that doesn't overlap content when the window is too small, b) the content element to stretch from the header to the footer so that I could put a background color in if I wanted, and c) the header to stretch across the entire window, j…
$page-header-height: 50px;
$page-footer-height: 50px;
$gutter: 20px;
.page-wrap {
max-width: 1024px;
margin: 0 auto;
@include box-sizing(border-box);
padding: 0 $gutter;
}
.page-header {
height: $page-header-height;
position: absolute;
top: 0;
left: 0;
right: 0;
}
.page-content {
min-height: 100%;
padding-top: $gutter + $page-header-height;
padding-bottom: $gutter + $page-footer-height;
margin-bottom: -$page-footer-height;
}
.page-footer {
height: $page-footer-height;
}
<!DOCTYPE html>
<html>
<head>
<!-- meta -->
<meta charset="UTF-8" />
<title>Layout</title>
<!-- styles -->
<link type="text/css" rel="stylesheet" href="/css/global.css" />
</head>
<body>
<header class="page-header">
<div class="page-wrap">
Header
</div>
</header>
<div class="page-content page-wrap">
Content
</div>
<footer class="page-footer">
<div class="page-wrap">
Footer
</div>
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment