【问题标题】:How to add a scrollbar style in Javascript?如何在 Javascript 中添加滚动条样式?
【发布时间】:2021-10-08 23:22:49
【问题描述】:

这是我在 HTML 中使用的功能滚动条样式,但我需要将其放入我的 JavaScript 代码中。

.large-2 {
  overflow: scroll;
  overflow-y: auto;
  overflow-x: hidden;
  height: 50%;
}

.large-2::-webkit-scrollbar-track {
  border: 1px solid #000000;
  padding: 2px 0;
  background-color: #404040;
}

.large-2::-webkit-scrollbar {
  width: 10px;
}

.large-2::-webkit-scrollbar-thumb {
  border-radius: 10px;
  box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  background-color: #737272;
  border: 1px solid #000;
}

【问题讨论】:

    标签: javascript jquery css styles scrollbar


    【解决方案1】:

    你可以为你的滚动条添加一个类名,而不是 div:

    div {
           height: 100px;
           overflow: auto;
        }
    

    参考此链接:Adding Scrollbars in HTML

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-18
      • 2011-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-27
      相关资源
      最近更新 更多