//Used to generate the html, not relevant to this question
for(var i=0;i<50;i++){
jQuery(".row").append(
'<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-3">'+
'<h1>Title '+i+'</h1>'+
'<img src="http://lorempixel.com/'+getRandomInt(300, 700)+'/'+getRandomInt(200, 800)+'">'+
'</div>');
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@media (min-width: 0) and (max-width: 544px) {
.row.same-width .col-xs-1:nth-child(12n + 13), html body > div.container ul.products .col-xs-1:nth-child(12n + 13),
html body > div.container-fluid ul.products .col-xs-1:nth-child(12n + 13) {
clear: left
}
.row.same-width .col-xs-2:nth-child(6n + 7), html body > div.container ul.products .col-xs-2:nth-child(6n + 7),
html body > div.container-fluid ul.products .col-xs-2:nth-child(6n + 7) {
clear: left
}
.row.same-width .col-xs-3:nth-child(4n + 5), html body > div.container ul.products .col-xs-3:nth-child(4n + 5),
html body > div.container-fluid ul.products .col-xs-3:nth-child(4n + 5) {
clear: left
}
.row.same-width .col-xs-4:nth-child(3n + 4), html body > div.container ul.products .col-xs-4:nth-child(3n + 4),
html body > div.container-fluid ul.products .col-xs-4:nth-child(3n + 4) {
clear: left
}
.row.same-width .col-xs-6:nth-child(2n + 3), html body > div.container ul.products .col-xs-6:nth-child(2n + 3),
html body > div.container-fluid ul.products .col-xs-6:nth-child(2n + 3) {
clear: left
}
.row.same-width .col-xs-12:nth-child(1n + 2), html body > div.container ul.products .col-xs-12:nth-child(1n + 2),
html body > div.container-fluid ul.products .col-xs-12:nth-child(1n + 2) {
clear: left
}
}
@media (min-width: 544px) and (max-width: 768px) {
.row.same-width .col-sm-1:nth-child(12n + 13), html body > div.container ul.products .col-sm-1:nth-child(12n + 13),
html body > div.container-fluid ul.products .col-sm-1:nth-child(12n + 13) {
clear: left
}
.row.same-width .col-sm-2:nth-child(6n + 7), html body > div.container ul.products .col-sm-2:nth-child(6n + 7),
html body > div.container-fluid ul.products .col-sm-2:nth-child(6n + 7) {
clear: left
}
.row.same-width .col-sm-3:nth-child(4n + 5), html body > div.container ul.products .col-sm-3:nth-child(4n + 5),
html body > div.container-fluid ul.products .col-sm-3:nth-child(4n + 5) {
clear: left
}
.row.same-width .col-sm-4:nth-child(3n + 4), html body > div.container ul.products .col-sm-4:nth-child(3n + 4),
html body > div.container-fluid ul.products .col-sm-4:nth-child(3n + 4) {
clear: left
}
.row.same-width .col-sm-6:nth-child(2n + 3), html body > div.container ul.products .col-sm-6:nth-child(2n + 3),
html body > div.container-fluid ul.products .col-sm-6:nth-child(2n + 3) {
clear: left
}
.row.same-width .col-sm-12:nth-child(1n + 2), html body > div.container ul.products .col-sm-12:nth-child(1n + 2),
html body > div.container-fluid ul.products .col-sm-12:nth-child(1n + 2) {
clear: left
}
}
@media (min-width: 768px) and (max-width: 992px) {
.row.same-width .col-md-1:nth-child(12n + 13), html body > div.container ul.products .col-md-1:nth-child(12n + 13),
html body > div.container-fluid ul.products .col-md-1:nth-child(12n + 13) {
clear: left
}
.row.same-width .col-md-2:nth-child(6n + 7), html body > div.container ul.products .col-md-2:nth-child(6n + 7),
html body > div.container-fluid ul.products .col-md-2:nth-child(6n + 7) {
clear: left
}
.row.same-width .col-md-3:nth-child(4n + 5), html body > div.container ul.products .col-md-3:nth-child(4n + 5),
html body > div.container-fluid ul.products .col-md-3:nth-child(4n + 5) {
clear: left
}
.row.same-width .col-md-4:nth-child(3n + 4), html body > div.container ul.products .col-md-4:nth-child(3n + 4),
html body > div.container-fluid ul.products .col-md-4:nth-child(3n + 4) {
clear: left
}
.row.same-width .col-md-6:nth-child(2n + 3), html body > div.container ul.products .col-md-6:nth-child(2n + 3),
html body > div.container-fluid ul.products .col-md-6:nth-child(2n + 3) {
clear: left
}
.row.same-width .col-md-12:nth-child(1n + 2), html body > div.container ul.products .col-md-12:nth-child(1n + 2),
html body > div.container-fluid ul.products .col-md-12:nth-child(1n + 2) {
clear: left
}
}
@media (min-width: 992px) and (max-width: 1200px) {
.row.same-width .col-lg-1:nth-child(12n + 13), html body > div.container ul.products .col-lg-1:nth-child(12n + 13),
html body > div.container-fluid ul.products .col-lg-1:nth-child(12n + 13) {
clear: left
}
.row.same-width .col-lg-2:nth-child(6n + 7), html body > div.container ul.products .col-lg-2:nth-child(6n + 7),
html body > div.container-fluid ul.products .col-lg-2:nth-child(6n + 7) {
clear: left
}
.row.same-width .col-lg-3:nth-child(4n + 5), html body > div.container ul.products .col-lg-3:nth-child(4n + 5),
html body > div.container-fluid ul.products .col-lg-3:nth-child(4n + 5) {
clear: left
}
.row.same-width .col-lg-4:nth-child(3n + 4), html body > div.container ul.products .col-lg-4:nth-child(3n + 4),
html body > div.container-fluid ul.products .col-lg-4:nth-child(3n + 4) {
clear: left
}
.row.same-width .col-lg-6:nth-child(2n + 3), html body > div.container ul.products .col-lg-6:nth-child(2n + 3),
html body > div.container-fluid ul.products .col-lg-6:nth-child(2n + 3) {
clear: left
}
.row.same-width .col-lg-12:nth-child(1n + 2), html body > div.container ul.products .col-lg-12:nth-child(1n + 2),
html body > div.container-fluid ul.products .col-lg-12:nth-child(1n + 2) {
clear: left
}
}
@media (min-width: 1200px) {
.row.same-width .col-xl-1:nth-child(12n + 13), html body > div.container ul.products .col-xl-1:nth-child(12n + 13),
html body > div.container-fluid ul.products .col-xl-1:nth-child(12n + 13) {
clear: left
}
.row.same-width .col-xl-2:nth-child(6n + 7), html body > div.container ul.products .col-xl-2:nth-child(6n + 7),
html body > div.container-fluid ul.products .col-xl-2:nth-child(6n + 7) {
clear: left
}
.row.same-width .col-xl-3:nth-child(4n + 5), html body > div.container ul.products .col-xl-3:nth-child(4n + 5),
html body > div.container-fluid ul.products .col-xl-3:nth-child(4n + 5) {
clear: left
}
.row.same-width .col-xl-4:nth-child(3n + 4), html body > div.container ul.products .col-xl-4:nth-child(3n + 4),
html body > div.container-fluid ul.products .col-xl-4:nth-child(3n + 4) {
clear: left
}
.row.same-width .col-xl-6:nth-child(2n + 3), html body > div.container ul.products .col-xl-6:nth-child(2n + 3),
html body > div.container-fluid ul.products .col-xl-6:nth-child(2n + 3) {
clear: left
}
.row.same-width .col-xl-12:nth-child(1n + 2), html body > div.container ul.products .col-xl-12:nth-child(1n + 2),
html body > div.container-fluid ul.products .col-xl-12:nth-child(1n + 2) {
clear: left
}
}
.row img{
width: 100%;
height: auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row same-width"></div>