html
<div>
<img src="http://www.hdwallpapersplus.com/wp-content/uploads/2013/06/abstract_color_background_picture_8016-wide.jpg" />
</div>
css
div{
width: 200px;
height: 100px;
background-color: red;
}
img{
position: relative;
width: 100%;
height: 100%;
background-size: cover;
}
Why background-size: cover doesn't work here. This should also be added in css3, but not added. Is there anyway not to stretch the image?
As we can do it with background: url("http://www.hdwallpapersplus.com/wp-content/uploads/2013/06/abstract_color_background_picture_8016-wide.jpg") no-repeat; background-size: cover;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…