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>     

enter image description here

update: problem visible in firefox.

you remove padding div , add inner elements.

http://jsfiddle.net/6ux1wjlc/

*, *: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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -