Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active January 3, 2016 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save billerickson/8463643 to your computer and use it in GitHub Desktop.
Save billerickson/8463643 to your computer and use it in GitHub Desktop.
Full with element in middle of page
// Make an element in the page go full width
// Author: Bill Erickson
// URL: http://www.billerickson.net/code/full-width-element-middle-page/
function explodeWidth() {
var browserWidth = $(document).width();
var wrapWidth = $('.site-inner .wrap').width();
var margin = ( ( browserWidth - wrapWidth ) / 2 );
$('.explode-width').css( 'margin-left', - margin ).css( 'margin-right', - margin );
}
explodeWidth();
$(window).resize(explodeWidth);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment