Skip to content

Instantly share code, notes, and snippets.

@rpheath
Created March 10, 2009 17:28
Show Gist options
  • Save rpheath/77018 to your computer and use it in GitHub Desktop.
Save rpheath/77018 to your computer and use it in GitHub Desktop.
// jQuery plugin
// - will adjust a content area to be at least as
// tall as the sidebar area
// Ex:
// $('#content').adjustHeightWithSidebar()
// $('#content').adjustHeightWithSidebar({sidebar_selector: '#side-bar'})
(function($) {
$.fn.adjustHeightWithSidebar = function(options) {
settings = $.extend({
sidebar_selector: '#sidebar'
}, options)
var content_height = $(this).height(),
sidebar_height = $(settings.sidebar_selector).height()
return this.each(function() {
if (sidebar_height > content_height)
$(this).height(sidebar_height)
})
}
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment