Last active
August 29, 2015 14:05
-
-
Save hastebrot/2ecb9a9a26505079bb64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
var atPosition = function($element, position) { | |
var top = $element[0] == window ? 0 : $element.position().top; | |
var height = $element.height(); | |
if (position == "top") { return top; } | |
if (position == "bottom") { return top + height; } | |
throw "unknown position"; | |
}; | |
var alignAbsolutePosition = function($element, top, height) { | |
$element.css("position", "absolute"); | |
$element.css("top", top); | |
$element.css("height", height); | |
}; | |
$(window).resize(function() { | |
var $window = $(window); | |
var $header = $("#header"); | |
var $content = $("#content"); | |
var topAnchor = atPosition($header, "bottom"); | |
var bottomAnchor = atPosition($window, "bottom"); | |
alignAbsolutePosition($content, topAnchor, bottomAnchor - topAnchor); | |
}); | |
$(window).trigger("resize"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment