html - 没有溢出时如何摆脱灰色滚动条?

标签 html css scrollbar overflow

我想在我的网页的某个部分添加一个垂直滚动条,如果它的内容变得太大,但即使内容足够小以适应,滚动条也会显示为灰色。我需要更改什么才能使滚动条仅在需要时显示?

示例代码:

<div id="aaa">
</div>

#aaa {
    background-color: #eee;
    width: 50px;
    height: 100px;
    overflow-y: scroll;
}

结果截图:

enter image description here

带有实例的 JSFiddle 链接:

http://jsfiddle.net/PGwg3/

最佳答案

这会起作用

overflow-y:auto;

关于html - 没有溢出时如何摆脱灰色滚动条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23165690/

相关文章:

html - 无法正确使用文本对齐 :justify

javascript - 如何让滚动条从底部开始

python - 滚动条 tkinter 不滚动

html - li :hover behaviour for my list is unpredictable?

html - 视差图像顶部的透明文本 div

html - 如何使用 "inline-block"和 CSS 将所有文本居中

javascript - 如何在快照 View 中向 Windows 8 应用程序添加垂直滚动

wpf - Treeview 虚拟化和不稳定的滚动

javascript - 滚动浏览富媒体网页的最流畅方式是什么?

html - 多行文本填充