【发布时间】:2014-04-06 16:41:10
【问题描述】:
我想以相同的比例显示图像。但是图像大小会有所不同。可能是 16:10 或 10:10 的宽高比。有些图像看起来是垂直的,有些图像看起来是水平的。
我用 div 做了背景封面中心。但是我必须用它来 img 元素。
如何使用 img 做到这一点?
div.image-content
{
width: 210px;
margin: 15px;
float: left;
height: 210px;
overflow: hidden;
background: no-repeat center center;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
【问题讨论】:
标签: css image background-image