我需要允许用户上传他们想要的任何像素,但他们的个人资料图片将超过 100x100。图片将包含在 SQUARE 框中。但问题是,当我上传 100x100 或类似尺寸的文件时,它的效果与预期的一样好。但是,当我上传像素为 640x360 或任何类似(或宽屏)像素的图像时,图像会很好地缩放到框内,但是它不是垂直对齐的。我希望垂直对齐位于中间,那么我该怎么做呢?
CSS:
#imgbox {
height:100px;
width:100px;
overflow:hidden;
border:solid 1px #000;
margin-left:10px;
margin-top:10px;
}
#imgbox img {
width:100%;
position:relative;
//I want the vertical align of the image to be in the center
}
这里:http: //jsfiddle.net/ZdW9h/1/