Skip to content

Instantly share code, notes, and snippets.

@zeshanshani
Last active April 17, 2019 23:17
Show Gist options
  • Save zeshanshani/77288a7701bcf1dd5870356cb46b00c4 to your computer and use it in GitHub Desktop.
Save zeshanshani/77288a7701bcf1dd5870356cb46b00c4 to your computer and use it in GitHub Desktop.
This JavaScript function will expand the sections to the 100% of browser window height.
/**
* Full Height Sections
* This function will expand the sections to the 100% of browser window height.
*
* Author: Zeshan Ahmed
* Author URI: http://www.zeshanahmed.com/
*
* Replace '#banner' with your targeted element's selector.
*/
jQuery(document).ready(function($) {
fullHeightSectionsContainer( '#banner' );
});
function fullHeightSectionsContainer( _el ) {
var _win = jQuery(window),
_wpadminbar = jQuery('#wpadminbar');
function fullHeightSections( _sec ) {
var _winThis = jQuery(window);
jQuery(_sec).each(function( i ) {
var _this = jQuery(this),
height = _win.outerHeight() - _wpadminbar.outerHeight();
_this.css( 'height', height );
});
}
_win.ready(function() {
fullHeightSections( _el );
}).resize(function() {
fullHeightSections( _el );
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment