【发布时间】:2015-12-30 14:45:47
【问题描述】:
我需要在某个 div 内设置图像的图像大小。我可以直接从 html 设置大小,但该网站是响应式的,我需要一些“特殊功能”。 我需要当容器 div 高度为 350px 时,它会停止垂直收缩,并开始水平裁剪。 我不能使用背景图像,并且使用最小高度它不能正确调整大小...... 我已经试过了:
CSS
#rslides_container {
position: relative;
float: left;
width: 100%;
height: auto;
min-height: 350px;
}
.rsimgsize {
width:100%;
height:auto;
overflow: hidden;
}
HTML
<div id="rslides_container">
<ul class="bxslider">
<li>
<img src="images/teste/cabeca.png" class="rsimgsize" />
<p class="caption">With the Flight Support Department, you can assure more than one service, that it will help you to save time.</p>
</li>
<li>
<img src="images/teste/cabeca2.png" class="rsimgsize" />
<p class="caption">With the Flight Support Department, you can assure more than one service, that it will help you to save time.</p>
</li>
<li>
<img src="images/teste/cabeca.png" class="rsimgsize" />
<p class="caption">With the Flight Support Department, you can assure more than one service, that it will help you to save time.</p>
</li>
<li>
<img src="images/teste/cabeca2.png" class="rsimgsize" />
<p class="caption">With the Flight Support Department, you can assure more than one service, that it will help you to save time.</p>
</li>
</ul>
</div>
【问题讨论】:
-
你的意思是当图像达到他的正常大小时就不会了?
-
@thommylue 号,他的正常尺寸是 1500x450。我希望当容器达到 350 高度时,img 停止调整大小,但容器继续......我希望 img 高度固定在 300px(容器有一条 50px 底部白线),容器高度固定在 350px,但是容器宽度会随着页面继续缩小(图像大小现在是固定的,并且有溢出)......
-
在下面查看我的答案:)