Change y-axis (horizontal) scrollbar styles

微笑、不失礼 提交于 2020-01-03 06:15:07

问题


I want to change the horizontal scrollbar styles of a div.

I successfully changed the x-axis (vertical) scrollbar style but when I added y-axis scroll, it is taking same styles as I added for the y-axis.

I want to style both scrollbars differently. Is there any possible way to make this happen?

Current CSS for (x-axis) vertical scrollbar:

 .list-group {
    overflow-y: scroll;
    max-height:  335px;
    border: 1px solid #bdbdbd;
    padding: 10px;
}
.list-group::-webkit-scrollbar {
    width:35px;
}
.list-group::-webkit-scrollbar-button:increment {
    background-image: url('../images/arrow down.png');
    background-repeat: no-repeat;
    height: 30px;
    border-bottom: 2px solid transparent;
}


.list-group::-webkit-scrollbar-button:decrement {
    background-image: url('../images/arrow up.png');
    background-repeat: no-repeat;
    height: 30px;
    border-top: 10px solid transparent;
}

回答1:


You can do this by simple apply overflow-y:scroll on that div. I hope this will help you.

div
{
 width: 30em;
    overflow-x: auto;
    white-space: nowrap;
 }

div::-webkit-scrollbar {
  width: 1em;
}

div::-webkit-scrollbar-track {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}

div::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background-color: #00bd86;
  outline: 2px solid slategrey;
}

div::-webkit-scrollbar:vertical {
  display: none;
}
<div>
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
  Its a test div
</div>


来源:https://stackoverflow.com/questions/43738245/change-y-axis-horizontal-scrollbar-styles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!