css - 收缩元素而不是整页

问题描述 投票:-1回答:1

我有一个包含2个div的页面。当我减小浏览器窗口的高度时,我希望第一个div缩小(并且滚动条出现在它上面),而第二个div应该保持它的高度。

是否可以用纯CSS实现这个逻辑?

<div class="shrinkit">
  ..many lines of text..
</div>
<div class="noscroll">
  ..many lines of text..
</div>
<style>
.shrinkit {
  background-color: blue;
}
.noscroll {
  background-color: green;
}
</style>
html css scrollbars
1个回答
0
投票

只需给第一个div height:auto;和第二个div,给你想要的高度,例如height:200px

© www.soinside.com 2019 - 2024. All rights reserved.