gpt4 book ai didi

css - 如何让滚动条一直出现?

转载 作者:太空宇宙 更新时间:2023-11-03 19:28:46 50 4
gpt4 key购买 nike

我创建了一个带滚动条的 div。但是当鼠标指针离开屏幕时,滚动条会隐藏。无论我的鼠标是否悬停,是否有可能显示滚动条在那里显示。?? 我用 Mozilla Firefox 和 chrome 试过了。

当您开始滚动时,会出现滚动条。完成后它会消失。

.scroll-div{

width:200px;
height:100px;
overflow-y:scroll;
}
.scroll-div::-webkit-scrollbar {
/* This is the magic bit */
display: block;
}
<div class="scroll-div">
test<br/>
test<br/>
test<br/>
test<br/>
test<br/>
test<br/>
test<br/>
test<br/>
test<br/>
test<br/>
test<br/>test<br/>

test<br/>
test<br/>
test<br/>
test<br/>test<br/>
test<br/>
test<br/>
test<br/>
</div>

最佳答案

你正在使用 ::-webkit-scrollbar 伪元素来设置滚动样式。但是在使用它时不显示浏览器的默认滚动条,这就是您看不到它的原因。此外,它仅在 webkit 浏览器中受支持。如果你想要自定义滚动条,你应该使用像 sly 和其他的 javascript 库。如果你想要默认滚动条,你可以删除这部分

.scroll-div::-webkit-scrollbar { 
/* This is the magic bit */
display: block;
}

有关自定义滚动条/滚动条样式的更多信息,请参阅此 link .

关于css - 如何让滚动条一直出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41442672/

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