html在全局中隐藏滚动条,我如何在div标签中显示它

标签 html css

如果我删除全局滚动条设置,则显示。

<body>
  <div class="content"></div>
</body>

body {
  ::-webkit-scrollbar {
    display: none
  }
}

.content {
  height: 10px
  overflow-y: scroll;
}

我试过了,但滚动条不总是消失;

.content::-webkit-scrollbar {
  display: none
}

最佳答案

改变

body {
  ::-webkit-scrollbar {
    display: none
  }
}

.content {
  height: 10px
  overflow-y: scroll;
}

.content {
  height: 10px;
  overflow-y: scroll;
}

而且你忘记了 ; 在你的高度.. 这是一个示例 fiddle .

关于html在全局中隐藏滚动条,我如何在div标签中显示它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46107412/

相关文章:

html - 居中对齐 Flex 行中元素内的文本

jquery - 单击后翻转卡不会卡住

jquery - 使用延迟在中间暂停 jquery 动画。有一些问题

javascript - 自适应布局上的垂直自适应图像对齐

html - Amp-sidebar : Does it absolutely have to be the child of the body? 为什么?

java - 在 Swing 中显示 HTML

javascript - 在 Canvas 上绘制像素并使用多个符号读取位置和颜色?

php - IE 中是否有 dir=auto 的替代属性

CSS - 填充包含 div 的剩余宽度

可以缩短多张 CD 的 css 选择器