【发布时间】:2019-04-01 02:40:56
【问题描述】:
这里是工作笔的链接:https://codepen.io/Adam0410/pen/OBqRRN
HTML
<div id="imgWrapper">
<img src="https://thestoryengine.co/wp-content/uploads/2017/11/The-crossroads-Section-images-02.png">
</div>
CSS
#imgWrapper {
display: flex;
justify-content: center;
width: 100%;
padding: 0 20px;
}
#imgWrapper img {
width: 100%;
max-width: 1660px;
height: auto;
}
我不希望图像超过其原始宽度(因此是最大宽度),但我希望它缩小到视口的宽度,同时保持其纵横比。目前,高度不随宽度缩放,这是为什么呢?
【问题讨论】:
标签: html css responsive-design responsive-images