【发布时间】:2016-09-29 13:23:11
【问题描述】:
如何防止我的图片被拉伸超过 200 像素的自然宽度?
footer {
display: flex;
}
img {
flex: 1;
margin: 1em;
}
<footer>
<img src=http://www.placebacon.net/200/150>
</footer>
【问题讨论】:
-
尝试删除img标签的flex属性。
-
不是答案,只是请注意,最好将所有 HTML 属性括在引号中。并在技术上用斜杠关闭标签。所以,placebacon.net/200/150" />
-
你是什么意思?将 img 设置为 100%; ?
-
图片需要怎么显示?在图像的原始宽度中?