html - Image not respecting the size of it's parents -
html - Image not respecting the size of it's parents -
i'm using flexslider , i'm wrapping img within div displayed inline-block. way, can contain other elements (a button on hover) within same div , position them relatively that. works expected on chrome on mozilla image seems disregard height or width restrictions set on it's parent elements , display in total size. heres quick codepen mimics issue. http://codepen.io/spylefkaditis/pen/hysbi
again works fine on chrome not on mozilla. ideas?
html:
<ul> <li> <div class="image"> <img src="http://lorempixel.com/1200/1800/" alt="" /> <!-- <a href="#" class="btn">button</a> <div class="modal"> <p class="message"></p> </div>--> </div> </li> </ul> scss:
*{ box-sizing:border-box; } html,body{ height:100%; width:100%; } ul{ margin:0; padding: 0; width: 100%; height:100%; list-style-type:none; li{ display:inline-block; position:relative; height:100%; width: 100%; text-align:center; .image{ position:relative; display:inline-block; text-align:center; img{ display: inline-block; max-height:100%; width:auto; } /* .btn{ position:absolute; left:0; bottom:0; background-color:black; } */ } } }
you need set height value .image element follows:
.image{ position:relative; display:inline-block; text-align:center; height: inherit; } otherwise, div.image expands height accommodate content, in case, big image.
see demo at: http://codepen.io/anon/pen/hptco
i tested in firefox , chrome , seems work okay.
html css
Comments
Post a Comment