javascript 如何强制滚动条出现在 ipad 中?(移动Safari)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14842876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 22:43:28  来源:igfitidea点击:

How to force a scroll bar to appear in the ipad? (Mobile Safari)

javascriptcssipadmobile-safari

提问by FairyQueen

I am having trouble getting a scroll bar to appear in mobile safari because overflow: auto does not work when there is scroll-able content. I found this css property:

我在移动 safari 中无法显示滚动条,因为 overflow: auto 在有可滚动内容时不起作用。我找到了这个 css 属性:

-webkit-overflow-scrolling: touch

-webkit-overflow-scrolling: 触摸

as some suggested this is a fix for mobile safari hiding the scroll bars but it's not working for me. Anyone have any suggestions on how I can force there to be a scroll bar in mobile safari to give the user a visual that they are supposed to scroll?

正如有人建议的那样,这是对隐藏滚动条的移动 safari 的修复,但它对我不起作用。任何人都对我如何强制在移动 safari 中有一个滚动条给用户一个他们应该滚动的视觉效果有任何建议?

回答by joseantgv

In your CSS include:

在你的 CSS 中包括:

::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 7px;
    height: 7px;
    -webkit-overflow-scrolling: auto;
}
::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: rgba(0,0,0,.5);
    -webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
}

Customize the appearance as needed.

根据需要自定义外观。

Stackoverflow source

Stackoverflow 源码

Original source

原始来源