html - 如何使 webkit 滚动条可见

标签 html css

在我的 HTML GUI 中有 3 个部分:---

  • 水平顶部(div 的类是可滚动 --- & --- div 的 ID 是 图片)
  • 垂直向左(div 的类是 scrollableMenu --- & --- ID div菜单)
  • 中心区域(div的类是scrollableCenter --- & --- div的ID是center)

    1. 当我按下按钮 1 时,我的 jQuery 代码(使用隐藏/显示方法) 在 Div scrollableMenu 中显示 7 个输入类型的 class-1 图像。
    2. 当我按下按钮 2 时,我的 jQuery 代码(使用隐藏/显示方法) 在 Div scrollableMenu 中显示 8 个 class-2 输入类型图像。
    3. 当我按下按钮 3 时,我的 jQuery 代码(使用隐藏/显示方法) 在 Div scrollableMenu 中显示 3 个输入类型图像的 class-3。
    4. 当我按下按钮 4 时,我的 jQuery 代码(使用隐藏/显示方法) 在 Div scrollableMenu 中显示 4 个输入类型图像的 class-1。

目前我只有webkit滚动条沿着DIV scrollableMenu垂直向下运行。
那是根据我的要求,即我只需要为 div scrollableMenu 垂直向下运行的 webkit 滚动条。

问题 我面临的是,万一 3 和 4 我的 webkit 滚动条变得不可见。

即使输入类型图像的数量较少,我的 webkit-scrollbar-track 是否有可能保持可见
我必须添加哪个属性才能至少使我的 webkit-scrollbar-track 可见


GUI View :

=========================================================

 Button-1   Button-2   Button-3    Button-4  Button-5

=========================================================
                 ||
                 ||
                 ||
      DIV        ||
 scrollableMenu  ||
                 ||
                 ||
                 ||
                 ||
                 ||
=========================================================

CSS:

div.scrollable {
    margin: 0;
    padding: 0;
    overflow: auto;
    padding-left: 4px;
    padding-top: 20px;
    box-sizing:border-box;
}

div.scrollableMenu {
    margin: 0;
    padding: 0;
    overflow: auto;
    padding-left: 4px;
    padding-top: 20px;
    box-sizing:border-box;
}

div.scrollableCenter {
    margin: 0;
    padding: 0;
    overflow: auto;
    padding-left: 4px;
    padding-top: 20px;
    box-sizing:border-box;
}

#images {
    background-color:#888686;
    white-space:nowrap;
}

#Menu {
    background-color:#292B3B;
    position:absolute;
    top:115px;
    bottom:20px;
    left:0;
    width:250px;
}
#center {
    background-color:#292B3B;
    position:absolute;
    top:115px;
    left:250px;
    right:0px;
    bottom:20px;
}


::-webkit-scrollbar-track {
      background-color: #DDDFED;
      border-radius: 20px;

}

::-webkit-scrollbar {
    background-color: #DDDFED;
    width: 10px;
    height: 10px;
} 

::-webkit-scrollbar-thumb {
    border-radius: 8px;
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
      background-color: #CCC9DA;
}

最佳答案

我猜你只想让垂直 (y) 滚动条可见。
不是水平 (x)。

您需要做的就是定义滚动条的位置(x 或 y):

div.scrollableMenu {
    margin: 0;
    padding: 0;
    overflow-y: scroll; /*(-y) here defines the direction of the scrollbar*/
    padding-left: 4px;
    padding-top: 20px;
    box-sizing:border-box;
}

如果出于某种原因底部滚动条仍然出现,请使用 overflow-x: hidden

编辑:
快速说明:
(y) = 垂直
(x) = 水平


Read more about CSS overflow property

关于html - 如何使 webkit 滚动条可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23101354/

相关文章:

html - 将一项从 float 定位更改为固定定位,CSS

html - 以 HTML5 格式嵌入 Vimeo 视频的好方法是什么?

html - CSS:Topbar 不跟随页面的滚动

当 div # 滚动到 View 中时,jQuery 在导航上更改 css

html - CSS/Bootstrap 样式问题

html - CSS 样式复选框

html - 在此html5音频代码中添加一个简单的 “pause”函数?

html - 为什么合并时缩小的 css 文件样式困惑,但放在 <head> 中时有效?

css - 覆盖样式 IE10 CSS

javascript - onclick 向按钮输入值