Skip to content

Instantly share code, notes, and snippets.

@sethrubenstein
Created September 6, 2013 13:57
Show Gist options
  • Save sethrubenstein/6464187 to your computer and use it in GitHub Desktop.
Save sethrubenstein/6464187 to your computer and use it in GitHub Desktop.
Bootstrap looped item grid
$(document).ready(function(){
var width = $(window).width();
var height = $(window).height();
var divs = $('.item');
if (width >= 1200 ){
for(var i = 0; i < divs.length; i+=4) {
divs.slice(i, i+4).wrapAll('<div class="row"></div>');
}
} else if (width >= 992){
for(var i = 0; i < divs.length; i+=3) {
divs.slice(i, i+3).wrapAll('<div class="row"></div>');
}
} else {
for(var i = 0; i < divs.length; i+=2) {
divs.slice(i, i+2).wrapAll('<div class="row"></div>');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment