gpt4 book ai didi

javascript - 更改 y 轴(水平)滚动条样式

转载 作者:太空宇宙 更新时间:2023-11-04 08:46:35 25 4
gpt4 key购买 nike

我想改变一个div的水平滚动条样式。

我成功地更改了 x 轴(垂直)滚动条的样式,但是当我添加 y 轴滚动条时,它采用的样式与我为 y 轴添加的样式相同。

我想为两个滚动条设置不同的样式。有什么方法可以实现这一目标吗?

(x 轴)垂直滚动条的当前 CSS:

 .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;
}

最佳答案

您可以通过简单地在那个 div 上应用 overflow-y:scroll 来做到这一点。希望对您有所帮助。

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>

关于javascript - 更改 y 轴(水平)滚动条样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43738245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com