html - CSS: Make img fit completely in div -


working on news site , once mobile, i'd image fits inside entire width of div....whatever might be. images 240px in width talking bumping them up. i'm using:

.thumb { float: left; clear: both; width: 100%; height: auto; margin: 0; } .thumb img { max-width: 100%; max-height: 100%; } 

so on iphone, pic little bit small since div 320px , img 240. of course, change say, landscape @ 480px example. needs flexible. suggestions?

you might try following, set image width 100%.

.thumb {    float: left;    clear: both;    width: 100%;    height: auto;    margin: 0;  }  .thumb img {    width: 100%;  }
<div class="thumb">    <img src="http://placehold.it/200x100">  </div>


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -