html - Bootstrap: How can I keep responsive images the same height even if they are not? -
i trying create gallery images in different widths this:
<div style="width: 900px;"> <div class="row"> <div class="col-xs-2"><img src="http://placehold.it/350x350" class="img-responsive"></div> <div class="col-xs-4"><img src="http://placehold.it/700x350" class="img-responsive"></div> <div class="col-xs-2"><img src="http://placehold.it/350x350" class="img-responsive"></div> <div class="col-xs-2"><img src="http://placehold.it/350x350" class="img-responsive"></div> <div class="col-xs-2"><img src="http://placehold.it/350x350" class="img-responsive"></div> </div> </div> so because responsive, 2nd image higher others. there simple way overflow: hidden; on 2nd image , therefor make same height others? image not distorted cut off @ bottom.
here fiddle: http://jsfiddle.net/2z1dalwt/
in order overflow:hidden work, you'll have set container fixed or percentage height, don't want various height , responsive images apparently. here jquery solution.
$(document).ready(function () { var min = infinity; $els = $('.row > div > img'); $els.each(function () { min = math.min($(this).height()); }); //alert(min); $els.parent('div').css({ 'height': min, 'overflow': 'hidden' }); });
Comments
Post a Comment