【发布时间】:2018-04-03 22:59:18
【问题描述】:
我正在尝试在左侧获取图像。随着窗口大小的变化,它应该缩放,保持纵横比。如果图像低于 600 像素,它应该滚动。在右边我想要图像的细节。像这样的:
到目前为止,我一直坚持让图像正确缩放。我能得到的最接近的是either the image covers the details 或pushes it bellow
.details {
float: right;
width: 200px;
background: green
}
.theImage {
width: 100%;
object-fit: contain;
object-fit: cover;
overflow: hidden;
}
.container {
background: red;
}
<div id="main">
<div class="details">
The details
</div>
<div class="container">
<img class="theImage" src="https://ichef.bbci.co.uk/images/ic/720x405/p0517py6.jpg">
</div>
</div>
【问题讨论】:
-
如果低于 600 像素应该滚动什么?目前还不清楚你指的是什么。您的问题来自没有定义图像容器的宽度。要么给它一个
float,要么明确地将其宽度设置为calc(100% - 200px)。 -
已编辑以使其更清晰。
-
但是什么应该滚动?
标签: css