【发布时间】:2019-04-18 12:42:59
【问题描述】:
我有这个代码:
.post-container {
overflow: auto
}
.post-thumb {
width: 300px;
height: 300px;
overflow: hidden;
}
.post-thumb img {
min-width: 100%;
}
<div class="post-container">
<div class="post-thumb"><img src="../images/logo.png" /></div>
</div>
我想展示一个不应该被拉伸的图像。但是现在侧面创建了一个滚动框来滚动图像的宽度,因为图像很长。
【问题讨论】:
-
只需设置
.post-thumb img {max-width: 100%; width: 100%;}而不是最小宽度 -
我相信你的说法自相矛盾。您不想让图像拉伸,但同时它不应该是它的原始大小,当它很长时?你的意思是它在保持比例的同时不应该增加超过 100% 的宽度?