【发布时间】:2013-11-19 11:40:16
【问题描述】:
Goody,想知道如何在不扭曲高度的情况下拉伸图像以适应宽度?也许只显示图像的中心部分?这是网站:
http://youthicons.my/2013/11/lorem-ipsum-dolar-sit-amet/
以及css的部分:
.featured-image, .featured-img{ top: 0; width: 100%; height: 537px; left: 0;}
谢谢!
【问题讨论】:
Goody,想知道如何在不扭曲高度的情况下拉伸图像以适应宽度?也许只显示图像的中心部分?这是网站:
http://youthicons.my/2013/11/lorem-ipsum-dolar-sit-amet/
以及css的部分:
.featured-image, .featured-img{ top: 0; width: 100%; height: 537px; left: 0;}
谢谢!
【问题讨论】:
height: auto; 而不是实际图像上的height: 537px。
如果你不希望它变得那么大,你可以在 div 上设置高度并设置 `overflow: hidden;'
【讨论】:
margin-top。您可能需要使用媒体查询来获取不同宽度的图像。如果您不希望图像大于实际宽度,也可以在图像上使用width: auto; max-width: 100%。