Created
September 22, 2014 11:32
-
-
Save frumbert/e6e4967436a58433fe88 to your computer and use it in GitHub Desktop.
For when you want an object in a container to fill the remaining height in a container object. Such as when you have a toolbar and want the content adjacent to it to fill the remaining height of the container div.
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
// e.g. $("#my-child-div").fillRemainingHeight(); | |
(function( $ ){ | |
$.fn.fillRemainingHeight = function( ) { | |
return this.each(function () { | |
var $this = $(this), | |
_h = $this.parent().height(), | |
_used = 0; | |
$this.siblings().each(function(){ _used+= $(this).outerHeight(); }); | |
$this.css("height", _h - _used); | |
}); | |
}; | |
})( jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$("#my-child-div").css("flex":"1").parent().css({"display":"flex","flex-direction":"column"});