Here is my effective solution that works seamlessly.
Check out the solution here
This solution was inspired by a comment from user jme11
.
CSS
.play-item {
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}
.v-wrapper {
max-width:1000px;
margin:0 auto;
}
.video-item-wrapper
{
border-bottom:30px solid green;
}
.video-image-wrapper {
position:relative;
width:100%;
}
.video-image-wrapper .img-responsive {
width:auto;
position:relative;
z-index:1;
}
.video-image-wrapper .play-item {
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
z-index:2;
}
/* add a little bottom space under the images */
@media (max-width: 767px) {
.portfolio>.clear:nth-child(2n)::before {
content: '';
display: table;
clear: both;
}
}
@media (min-width: 768px) and (max-width: 989px) {
.portfolio>.clear:nth-child(4n)::before {
content: '';
display: table;
clear: both;
}
}
@media (min-width: 990px) and (max-width: 1199px) {
.portfolio>.clear:nth-child(6n)::before {
content: '';
display: table;
clear: both;
}
}
@media (min-width: 1200px) {
.portfolio>.clear:nth-child(8n)::before {
content: '';
display: table;
clear: both;
}
}
HTML
<div class="container">
<div class="row v-wrapper portfolio">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<div class="video-item-wrapper">
<div class="video-image-wrapper">
<img src="http://placehold.it/600x400" class="img-responsive" />
<img src="http://placehold.it/50.png/09f/fff&text=>" class="play-item" />
</div>
<div class="video-details-wrapper"> <span>this is video short video title</span>
</div>
</div>
</div>
<div class="clear"></div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<div class="video-item-wrapper">
<div class="video-image-wrapper">
<img src="http://placehold.it/600x400" class="img-responsive" />
<img src="http://placehold.it/50.png/09f/fff&text=>" class="play-item" />
</div>
<div class="video-details-wrapper"> <span>this is long video title this is long video title this is long video title</span>
</div>
</div>
</div>
<div class="clear"></div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<div class="video-item-wrapper">
<div class="video-image-wrapper">
<img src="http://placehold.it/600x400" class="img-responsive" />
<img src="http://placehold.it/50.png/09f/fff&text=>" class="play-item" />
</div>
<div class="video-details-wrapper"> <span>this is very very long video title this is very very long video title this is very very long video title</span>
</div>
</div>
</div>
<div class="clear"></div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<div class="video-item-wrapper">
<div class="video-image-wrapper">
<img src="http://placehold.it/600x400" class="img-responsive" />
<img src="http://placehold.it/50.png/09f/fff&text=>" class="play-item" />
</div>
<div class="video-details-wrapper"> <span>this is video title</span>
</div>
</div>
</div>
<div class="clear"></div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<div class="video-item-wrapper">
<div class="video-image-wrapper">
<img src="http://placehold.it/600x400" class="img-responsive" />
<img src="http://placehold.it/50.png/09f/fff&text=>" class="play-item" />
</div>
<div class="video-details-wrapper"> <span>this is video title</span>
</div>
</div>
</div>
<div class="clear"></div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<div class="video-item-wrapper">
<div class="video-image-wrapper">
<img src="http://placehold.it/600x400" class="img-responsive" />
<img src="http://placehold.it/50.png/09f/fff&text=>" class="play-item" />
</div>
<div class="video-details-wrapper"> <span>this is video title this is video title this is video title this is video title</span>
</div>
</div>
</div>
<div class="clear"></div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<div class="video-item-wrapper">
<div class="video-image-wrapper">
<img src="http://placehold.it/600x400" class="img-responsive" />
<img src="http://placehold.it/50.png/09f/fff&text=>" class="play-item" />
</div>
<div class="video-details-wrapper"> <span>this is video title</span>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
Utilizing jQuery for optimizing vertical spacing between rows in Bootstrap layout (source)
I have identified an issue with the current approach where uneven heights of divs can result in unnecessary space adjustments. This script addresses the issue:
View the enhanced example on Fiddle
var row=$('.portfolio');
$.each(row, function() {
var maxh=0;
$.each($(this).find('div[class^="col-"]'), function() {
if($(this).height() > maxh)
maxh=$(this).height();
});
$.each($(this).find('div[class^="col-"]'), function() {
$(this).height(maxh);
});
});