css - 如何禁用 sidenav 上的滚动

标签 css

我想问

我有一个显示隐藏菜单(openNav,closeNav)

这是我的 javascript :

function openNav() {
    document.getElementById("mySidenav").style.width = "100%";
    // document.getElementById("flipkart-navbar").style.width = "50%";
    document.body.style.backgroundColor = "rgba(0,0,0,0.4)";
}

function closeNav() {
    document.getElementById("mySidenav").style.width = "0";
    document.body.style.backgroundColor = "rgba(0,0,0,0)";
}

这是我的 css 脚本:

.sidenav {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    background-color: #fff;
    overflow-x: hidden;
    transition: 0.5s;
    box-shadow: 0 4px 8px -3px #555454;
    padding-top: 0px;
}

我尝试添加 overflow-y: hidden;但不工作

我尝试将 overflow:visible 或 auto not work 更改为

我尝试将位置更改为绝对位置或相对位置对先生不起作用

滚动仍然显示

这是我的截图:

enter image description here

从我的截图中看到滚动条,滚动条显示没有隐藏或禁用

先生,如何隐藏或禁用滚动条?

先谢谢

最佳答案

尝试

overflow: hidden;
height:100vh;
width: 100vh;

关于css - 如何禁用 sidenav 上的滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50733754/

相关文章:

CSS 验证问题

html - 表格列的最佳自动宽度

javascript - 如何获取名称的首字母并将其用作商店的简介

html - 将包含 3 个 float div 的容器居中到左侧

javascript - .mouseover 在放下元素后停止工作

html - 带文字的 CSS 梯形形状

html - 如何只显示 textarea 字段,而不显示它下面的行?

html - Bootstrap Glyphicons 不会显示,除非所有文件都在根目录中

css - 如何在 Bootstrap 网格系统中对齐文本?

html - 如何删除带有背景颜色的表格单元格分隔符