2013-03-13 145 views
5

如何在溢出时隐藏Firefox滚动条:auto?隐藏Firefox浏览器滚动条

:: - webkit-scrollbar { display:none; }

我使用此代码,但这只适用于Google Chrome。

有帮助吗?谢谢!

更新

当我用

溢出:隐藏;

我的页面无法继续页脚。

<html> 
<head> 
<link rel="stylesheet" href="css/style.css" type="text/css" /> 
</head> 

<body> 

<div id="pageWrapper"> 
    <header></header><!--end of header--> 

    <nav> 
     <ul> 
      <li><a href="#">Home</a></li>| 
      <li><a href="#">Services</a></li>| 
      <li><a href="#">Gallery</a></li>| 
      <li><a href="#">FAQ</a></li>| 
      <li><a href="#">About Us</a></li>| 
     </ul> 
    </nav><!--end of nav--> 

    <aside> 

    </aside><!--end of aside--> 

    <section> 
    </section><!--end of section--> 
    <footer>All Right Reserved 2013.</footer><!--end of footer--> 
</div><!--end of pageWrapper--> 

</body> 
</html> 

我的CSS

/*----- Reset ----*/ 
html, body, div, span, object, h1, h2, h3, h4, h5, h6, p, 
blockquote, pre, a, address, code, img, small, strong, 
dl, dt, dd, ol, ul, li, fieldset, form, label{ 
margin:0; 
padding:0; 
border:0; 
outline:0; 
font-size:100%; 
vertical-align:baseline; 
background:transparent; 
} 
body{ 
line-height:1.5; 
font-family: helvetica, arial, sans-serif; 
} 

body,html{ 
    height:100%; 
    background-color:whitemsoke; 
} 

ol, ul{ 
list-style:none; 
} 

/* ---- END OF RESET --- */ 
#pageWrapper{ 
    width:965px; 
    height:100%; 
    margin:auto; 
    box-shadow:1px 1px 17px black; 
    overflow:hidden; 
} 
::-webkit-scrollbar { 
    display:none; 
} 
header{ 
    background-color: #D4E7ED; 
    height:200px; 
} 
nav{ 
    text-align:center; 
    background-color:#003366; 
    padding:10px; 
} 
nav ul li{ 
    display:inline; 
    padding:20px; 
} 
nav ul li a{ 
    text-decoration:none; 
    color:whitesmoke; 
} 
nav ul li a:hover{ 
    text-decoration:underline; 
} 
aside{ 
    width:200px; 
    background-color:#666666; 
    height:100%; 
    overflow:hidden; 
    float:left; 
    margin:0 auto -20px 0; 
} 
section{ 
    background-color:#CCCCCC; 
    height:100%; 
    margin:0 auto -20px 0; 
    overflow:hidden; 
} 
footer{ 
    background-color:#003366; 
    height:20px; 
    position:relative; 
} 
+2

为什么不使用'overflow:hidden'? – 2013-03-13 18:59:23

+0

我会试试这位先生,谢谢。但是当使用overflow时,无法在Firefox中隐藏滚动条:auto? – 2013-03-13 19:12:02

+0

它不工作我看不到我的页脚:| – 2013-03-13 19:15:15

回答

10

我没有找到具体到Firefox什么。我也一直在寻找相当于::-webkit-scrollbar { display:none }

我没发现,但是,是一个通用的跨浏览器的解决方案:

<div class="outer"> 
    <div class="inner"> 
     Some content... 
    </div> 
</div> 

<style> 
.outer { 
    overflow: hidden; 
} 
.inner { 
    margin-right: -16px; 
    overflow-y: scroll; 
    overflow-x: hidden; 
} 
</style> 

滚动条由父DIV隐藏。

这需要您在父div中使用overflow:hidden,但除此之外,它的作用类似于魅力。

+0

margin-right:-16px非常聪明! – duhaime 2016-09-28 19:56:22

+0

如果您选择此选项,请考虑每个浏览器上滚动条的大小不同,请特别注意触摸屏设备。 – Grirg 2017-09-14 15:50:54

+0

当内部div内容长于屏幕宽度时,它不会在FF 56上工作 – 2017-11-04 19:37:22