我正在为Web应用程序使用布局,其中左侧有一个侧边栏菜单。菜单由几个项目组成,可以展开以显示菜单子项目。我的问题是:展开几个项目时,菜单侧栏的高度超过了屏幕的高度。此外,侧边栏确实允许ot滚动查看列表中的最后一个菜单项。
这是我的侧边栏的css部分:
.sidebar {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 260px;
display: block;
z-index: 1;
color: #fff;
font-weight: 200;
}
.sidebar .sidebar-wrapper {
position: relative;
z-index: 4;
width: 260px;
height: calc(100vh - 64px);
overflow-y: scroll;
}
如您所知,我希望滚动边栏,但无法正常工作。
关于如何实现这一目标的任何想法?
非常感谢。
亚当
答案 0 :(得分:0)
我认为这应该可以帮助您实现这一目标
<style>
.sidebar {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 260px;
display: block;
z-index: 1;
color: #fff;
font-weight: 200;
}
.sidebar-wrapper {
position: relative;
z-index: 4;
width: 260px;
height: calc(100vh - 64px);
overflow-y: scroll;
}
</style>
<div class="sidebar-wrapper">
<div class="sidebar"></div>
</div>