css 内容可滚动到屏幕底部

qncylg1j  于 2023-03-14  发布在  其他
关注(0)|答案(1)|浏览(263)

我有这个布局,我正在努力实现。基本上类似于Facebook的消息(facebook.com/messages
我一直在这里尝试,但运气不好:https://jsfiddle.net/3nd0b17m/23/

基本上屏幕部分滚动条应该结束在屏幕的最后,现在进一步下降。有人能帮我实现这一点吗?

rjee0c15

rjee0c151#

我将如何去做这件事,是使侧边栏的位置固定,以确保它停留在很好的地方,而你滚动页面的其余部分。
下面是一个更新的小提琴:https://jsfiddle.net/odukje08/3/
祝你好运!
编辑:我在侧边栏中添加了一些flex属性,使其React更灵敏,并且始终具有正确的高度。

.container {
  display: flex;
  height: 2000px;
  overflow-y: hidden;
}

.left {
  background-color: red;
  width: 20%;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.left-bottom {
  background-color: green;
  height: 100%;
  overflow-y: auto;
  
}
.right {
  flex-grow: 1;
  padding-left: 20%;
}
<div class="container">
  <div class="left">
    <div class="left-top">
    <p>
    This is the top
    </p>
    </div>
    <div class="left-bottom">
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
      <p>
      stuff
      </p>
    </div>
  </div>
  <div class="right">
  <h1>
  hello
  </h1>
  <p>
  this is the right side. You can scroll me too!
  </p>
  </div>
</div>

相关问题