直接解决这个问题:我正在开发HTML和CSS的侧边栏菜单。一切在计算机设备上都可以正常运行,但在移动设备上,该页面直到页面末尾才滚动。我不知道问题出在哪里,但我将提供我编写的代码,以便有人可以帮助我解决问题。
HTML部分
<div class="sidemenu">
<div class="topmenu">
/* The rest of the code
</div>
<div class="menucontent">
/* The rest of the code
</div>
</div>
CSS部分
.sidemenu {
position: fixed;
width: 400px;
height: 100vh;
left: 0;
background-color: #FFFFFF;
transition: all 0.3s ease-in-out;
z-index: 1;
}
.topmenu {
width: 100%;
height: 84px;
border-bottom: 1px solid #000;
}
.menucontent {
position: relative;
width: 100%;
min-height: calc(100% - 84px);
max-height: calc(100% - 84px);
overflow-y: auto;
padding: 15px;
}
答案 0 :(得分:0)
我修复了它。我只是替换了高度:从侧边栏到100%的100vh
答案 1 :(得分:0)
简单修复。您已在侧边菜单上设置了position: fixed
。删除它,它会正常滚动