html - Border-box breaks the container of the responsive image -
i have <div>, fixed height , padding. border-box property applied on whole page. inside <div> have <img> max-width:100%, , max-height:100% properties. problem container wider excepted (i think because of padding).
what best solution add padding around image without breaking design or how fix it?
i saved jsfiddle (http://jsfiddle.net/4eo6bebj/) , added question.
*, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } #responsive-image { height:150px; border:1px solid red; display:inline-block; float:left; padding:15px; } img { max-width:100%; max-height:100%; } <div id="responsive-image"> <img src="http://lorempixel.com/400/200/sports/"> </div> 
update: problem visible in firefox.
you remove padding div , add inner elements.
*, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } #responsive-image { height:150px; border:1px solid red; float:left; } #responsive-image * { padding: 10px; } img { max-width:100%; max-height:100%; } <div id="responsive-image"> <img src="http://lorempixel.com/400/200/sports/" /> </div>
Comments
Post a Comment