如果您不一定需要使用图像标记,则使用图像作为容器的背景可以轻松地执行您想要的操作。
Jsfiddle样本:http://jsfiddle.net/zEP9L/
HTML:
Don't want the white space. Instead, should crop width to fill complete container.
This looks ok, but would like to control the crop - eg show the center of the image, not the top
This is an alternative option
.container { width: 180px; height: 160px; overflow: hidden; border:red solid 2px }
.container img { width:100%}
#something {
background-image: url("http://3.bp.blogspot.com/-LAfvYIuz6c4/UpQxIe-FlmI/AAAAAAAAAcE/DVeCw1W6Yu4/s320/Eggless+Mini+Apple+Pie.JPG");
background-size: cover;
background-position: center center;
}