Html 在 Safari 上强制滚动条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8946869/
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-08-29 12:40:22  来源:igfitidea点击:

force scrollbar on Safari

htmlcss

提问by Chapsterj

Is there a way to force the vertical scrollbar to show on Safari Lion. It only shows if you click the far right of a page. I have an element where I have overflow-y:auto but in Safari it doesn't show until you click the edge of the element.

有没有办法强制垂直滚动条显示在 Safari Lion 上。它仅在您单击页面最右侧时显示。我有一个元素,其中有溢出-y:auto,但在 Safari 中,直到您单击元素的边缘,它才会显示。

回答by Chapsterj

Ok found this online at this site http://css-tricks.com/custom-scrollbars-in-webkit/This will make it show up in Safari Lion

好的,在本网站http://css-tricks.com/custom-scrollbars-in-webkit/在线找到了这个, 这将使其显示在 Safari Lion 中

::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 8px;
}

::-webkit-scrollbar-track {
    background-color: rgba(57,57,57, .6);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background-color: rgba(156, 156, 156, .6);
}

Obviously you will need to change the properties to suite what you want. Again this is for Safari as overflow-y: scroll;does not force it to show.

显然,您需要更改属性以适应您的需求。这再次适用于 Safari,因为overflow-y: scroll;它不会强制显示。

If you want to assign this to a scrollbar on a specific element, you can add any css selector before:

如果要将其分配给特定元素上的滚动条,可以在之前添加任何 css 选择器:

.mydiv::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 8px;
}

.mydiv::-webkit-scrollbar-track {
    background-color: rgba(57,57,57, .6);
    border-radius: 8px;
}

.mydiv::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background-color: rgba(156, 156, 156, .6);
}

回答by rebz

Apply the overflow-y to the html element. html { overflow-y:scroll; }

将溢出-y 应用于 html 元素。 html { overflow-y:scroll; }