html - CSS: Make object-fit work with min-height -
is there way make object-fit
work min-height
?
see jsfiddle example.
if set fixed height
, works, if set min-height
, doesn't work.
html:
<div class="container"> <div class="b_feat_img"> <img src="http://i.imgur.com/iejwyxn.jpg"> </div> </div>
css:
.container { width:120px; } .b_feat_img { border: 1px solid green; background: red; float: left; height: auto; min-height:130px; margin-bottom: 10px; overflow: hidden; width: 100%; } .b_feat_img img { object-fit: cover; height: 100%; width: 100%; }
the min-height
needs set on img
element, not container.
in additional, can set vertical-align:top
or display:block
on img
rid of unwanted whitespace below it.
.container { width:120px; } .b_feat_img { border: 1px solid green; background: red; float: left; height: auto; margin-bottom: 10px; overflow: hidden; width: 100%; } .b_feat_img img { object-fit: cover; min-height: 130px; width: 100%; vertical-align: top; }
<div class="container"> <div class="b_feat_img"> <img src="http://i.imgur.com/iejwyxn.jpg"> </div> </div>
Comments
Post a Comment