CSS 在 Mac OS X 上的 Firefox 中强制可见滚动条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18317634/
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
Force visible scrollbar in Firefox on Mac OS X
提问by Boschman
Firefox 24 introduced Lion scrollbar support. This will show scrollbars in Lion style on Mac OS X. See: https://wiki.mozilla.org/Lion_Scrollbars/Triage
Firefox 24 引入了 Lion 滚动条支持。这将在 Mac OS X 上以 Lion 样式显示滚动条。请参阅:https: //wiki.mozilla.org/Lion_Scrollbars/Triage
This causes a problem for me: a scrollbar on a div is now hidden by default. Sometimes I want to force a visible scrollbar.
这给我带来了一个问题:div 上的滚动条现在默认隐藏。有时我想强制显示滚动条。
For WebKit there is a nice solution (mentioned at https://davidwalsh.name/osx-overflow):
对于 WebKit,有一个很好的解决方案(在https://davidwalsh.name/osx-overflow 中提到):
::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
}
::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: rgba(0,0,0,.5);
-webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
}
Does anybody know how I can force a visible scrollbar in Firefox 24 (and up) on Mac OS X?
有谁知道我如何在 Mac OS X 上的 Firefox 24(及更高版本)中强制显示滚动条?
Are there any drop-in javascript scrollbars that match webkit scrollbars?
是否有任何与 webkit 滚动条匹配的嵌入式 javascript 滚动条?
采纳答案by Claudio Holanda
As user thirtydot explainedin another question, there is no way to customize scrollbars in Firefox as its possible in Chrome.
正如用户三十多点在另一个问题中所解释的那样,无法像在 Chrome 中那样在 Firefox 中自定义滚动条。
Also, there is no way to actually "force" Firefox render the old-style scrollbar since the default scrollbar used in the system is predefined by the OS itself(note that you can modify which scrollbar you want in System Preferences).
此外,由于系统中使用的默认滚动条是由操作系统本身预定义的(请注意,您可以在系统偏好设置中修改所需的滚动条),因此无法真正“强制”Firefox 呈现旧式滚动条。
In other words, until Firefox supports native custom scrollbars, it is only possible with JavaScript plugins such as jScrollPaneand similar.
换句话说,在 Firefox 支持本机自定义滚动条之前,只能使用 JavaScript 插件,例如jScrollPane等。
回答by Confidant
Here's a solution but you have to use Javascript. Basically it runs a loop that forces the browser to show the scrollbars.
这是一个解决方案,但您必须使用 Javascript。基本上它运行一个循环,强制浏览器显示滚动条。
Use this CSS to make sure your div is set to show scrollbars:
使用此 CSS 确保您的 div 设置为显示滚动条:
.mydiv{ overflow-y:auto; }
Then attach this script to your page (this requires JQuery).
然后将此脚本附加到您的页面(这需要 JQuery)。
<script type="text/JavaScript">
var sc;
jQuery(document).ready(function(){
//constantly update the scroll position:
sc=setInterval(scrollDown,200);
//optional:stop the updating if it gets a click
jQuery('.mydiv').mousedown(function(e){
clearInterval(sc);
});
});
function scrollDown(){
//find every div with class "mydiv" and apply the fix
for(i=0;i<=jQuery('.mydiv').length;i++){
try{
var g=jQuery('.mydiv')[i];
g.scrollTop+=1;
g.scrollTop-=1;
} catch(e){
//eliminates errors when no scroll is needed
}
}
}
</script>
回答by Fernando Camargo
How about overflow: -moz-scrollbars-vertical
?
怎么样overflow: -moz-scrollbars-vertical
?