在旧的mozilla版本中隐藏滚动条,保留滚动



我正在编写一个布局,它有三列独立的可滚动图片,就像这个页面一样。不同的是,在我们的设计中,图像之间只有一个像素。我设法用chrome和最新的Firefox隐藏了滚动条。在Firefox 63.0.1中,它们仍然存在,我需要隐藏它们,同时仍然保留-能够单独向下滚动div-图片之间的距离为1px或更宽,仅适用于那些较旧的firefox版本。

大多数情况下,我试图通过隐藏在外容器上的溢出来隐藏视觉。对于Chrome来说,它是有效的。

-ms-overflow-style: -ms-autohiding-scrollbar;
::-webkit-scrollbar {
display: none;
}

我在这里找到了这个:

#parent{
height: 100%;
width: 100%;
overflow: hidden;
}
#child{
width: 100%;
height: 100%;
overflow-y: scroll;
padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
box-sizing: content-box; /* So the width will be 100% + 17px */
}

在这里我找到了

body.is-firefox . scroll-container {
overflow: hidden;
-webkit-transform: translateX(-18px);
-ms-transform: translateX(-18px);
transform: translateX(-18px);
}
body.is-firefox .scroll-container .inner {
height: 100%;
-webkit-transform: translateX(18px);
-ms-transform: translateX(18px);
transform: translateX(18px);
overflow-y: scroll;
overflow-x: hidden;
}

如果我能在图像之间有超过1px的空白,那就太好了。或者我确信这个设备不是Firefox的最新版本,那么我也许可以使用这些技巧。

我搜索并阅读到,识别功能比识别浏览器更正确、更现实。尝试使用modernizr了解用户浏览器支持的哪些功能

.no-cssscrollbar .box { 
color: red;
}
.cssscrollbar .box {
color: green;
}

不确定我是否检测到了正确的功能,或者它是否能检测到我想要的东西。在代码笔的例子中,它似乎在某种程度上起作用。但如果我在我的网页上尝试,Chrome也有那些"无cssscrollbar"类,尽管我在Chrome中看不到任何滚动条,而且有可能隐藏它们。

无论如何:我在firefox63.0.1中仍然有滚动条,我想旧版本也是如此。

请帮助我获得代码:-确定使用的浏览器是否可以隐藏滚动条-确定使用的浏览器是否为旧版Firefox

谢谢

在此处使用此CSS:

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* 
only needed once */
:-moz-any(#content,#appcontent) browser{
margin-right:-14px!important;
overflow-y:scroll;
margin-bottom:-14px!important;
overflow-x:scroll;
}

来源:https://support.mozilla.org/en-US/questions/1216436#answer-1108340

最新更新