Center an `<img>` in a `<div>`
问题 How do I center an <img> in a containing <div> ? The usual margin-left: auto; margin-right: auto; isn't working. The image can be larger than the container, and is scaled either horizontally or vertically by the max-width and max-height . A jsfiddle with the below code: http://jsfiddle.net/9ShGj/1/ HTML: <div class="container"> <img src="http://www.yensa.com/fat/fat-dude10.jpg" /> </div> <div class="container"> <img src="http://oi43.tinypic.com/bje2wn.jpg" /> </div> CSS: .container { width: