当主体溢出设置为隐藏时,如何为侧面板添加滚动条?
How can I add a scrollbar for side panel when the body overflow is set to hidden?
这是 JSFiddle:
https://jsfiddle.net/stgeqjoL/
html,
body,
#container {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
我有一个侧面板,其中有许多 div,当被选中时会执行某些操作。
主体当前设置为隐藏溢出,这使得侧面板也隐藏了溢出,但我希望它滚动。
我需要更改什么?
您需要向 #sidebar
添加 height
值以及 overflow: scroll
。
尝试:
#sidebar {
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.85);
width: 350px;
overflow: scroll;
height: 100vh;
}
这是 JSFiddle:
https://jsfiddle.net/stgeqjoL/
html,
body,
#container {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
我有一个侧面板,其中有许多 div,当被选中时会执行某些操作。
主体当前设置为隐藏溢出,这使得侧面板也隐藏了溢出,但我希望它滚动。
我需要更改什么?
您需要向 #sidebar
添加 height
值以及 overflow: scroll
。
尝试:
#sidebar {
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.85);
width: 350px;
overflow: scroll;
height: 100vh;
}