简体   繁体   English

使用-webkit-overflow-scrolling时更改HTML滚动条颜色:触摸

[英]change HTML scrollbar color when using -webkit-overflow-scrolling: touch

I have a iOS app that has a WebKit webview (WKWebView) and I want to change the color of the scrollbar in my HTML with CSS while still retaining the touch / throw acceleration scrolling. 我有一个具有WebKit Webview(WKWebView)的iOS应用,我想用CSS更改HTML中滚动条的颜色,同时仍保持触摸/抛出加速滚动。

I have tried using: 我试过使用:

::-webkit-scrollbar-thumb {
    background-color: #ff4872;
}

...but to no avail. ...但无济于事。 Because it doesn't change the color unless I set the webkit scrolling setting to scroll: 因为除非将webkit滚动设置设置为“ scroll”,否则它不会改变颜色:

-webkit-overflow-scrolling: scroll;

...which takes away the Safari-like acceleration scrolling. ...消除了类似Safari的加速滚动。 I would like a pure CSS solution if possible, but I can do JavaScript or JQuery if that is the only option. 如果可能的话,我想要一个纯CSS解决方案,但是如果那是唯一的选择,我可以使用JavaScript或JQuery。

JSFiddle: https://jsfiddle.net/rmcadbmq/3/ JSFiddle: https ://jsfiddle.net/rmcadbmq/3/

Using Below code you will solve your issue 使用下面的代码,您将解决您的问题

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

I think it will work for you: 我认为它将为您工作:

.scrollContainer::-webkit-scrollbar-thumb {
    background: #ff4872; 
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(112,0222,0,0.5);

}
.scrollContainer {
    font-size: 2em;
    width: 300px;
    height: 440px;
    background-color: #eee;
    overflow: scroll;
}

.scrollTest {
    width: 270px;
    height: 440px; 
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS:-webkit-overflow-scrolling:触摸和滚动 - iOS: -webkit-overflow-scrolling:touch and scrollTop Safari iOS7:使用-webkit-overflow-scrolling时无法隐藏底栏:touch; - Safari iOS7: Bottom bar can't be hidden when using -webkit-overflow-scrolling: touch; 使用-webkit-overflow-scrolling:touch时的当前滚动位置:Safari iOS javascript事件(scrollTop / scrollLeft) - Current scroll position when using -webkit-overflow-scrolling:touch - Safari iOS javascript event (scrollTop / scrollLeft) -webkit-overflow-scrolling:自动; 在触控装置上无法运作 - -webkit-overflow-scrolling: auto; not working on touch devices 移动网络:-webkit-overflow-scrolling:触摸与位置冲突:已修复 - Mobile web: -webkit-overflow-scrolling: touch conflicts with position:fixed scrollLeft通过-webkit-overflow-scrolling自动返回到旧位置: - scrollLeft automatically returning to old position with -webkit-overflow-scrolling: touch 任何方式应用'webkit-overflow-scrolling:touch'内嵌javascript? - Any way to apply 'webkit-overflow-scrolling: touch' inline with javascript? -webkit-overflow-scrolling:触摸导致jQuery动态更改不显示? - -webkit-overflow-scrolling: touch causes jQuery dynamic changes to not show? scrollTop不能与-webkit-overflow-scrolling一起使用:touch - scrollTop doesn't work with -webkit-overflow-scrolling: touch “-webkit-overflow-scrolling:touch” - 滚动的内容是隐藏的吗? - “-webkit-overflow-scrolling: touch” - scrolled content is hidden?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM