Skip to content

Instantly share code, notes, and snippets.

@frumbert
Created September 22, 2014 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frumbert/e6e4967436a58433fe88 to your computer and use it in GitHub Desktop.
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.
// 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 );
@frumbert
Copy link
Author

frumbert commented Sep 2, 2019

$("#my-child-div").css("flex":"1").parent().css({"display":"flex","flex-direction":"column"});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment