当身体溢出设置为隐藏时,如何为侧面板添加滚动条?

时间:2017-08-03 23:17:33

标签: html css overflow

这是JSFiddle:

https://jsfiddle.net/stgeqjoL/

html,
body,
#container {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

我有一个侧面板,它有很多div,可以在选中时执行某些操作。

正文设置为隐藏溢出,这使得侧面板也隐藏了溢出,但我希望它能够滚动。

我需要改变什么?

1 个答案:

答案 0 :(得分:0)

您需要向height添加#sidebar值以及overflow: scroll

尝试:

#sidebar {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.85);
    width: 350px;
    overflow: scroll;
    height: 100vh;
}
相关问题