2013-12-07 121 views
11

我有這樣的CSS:不能隱藏滾動條:汽車

.div { 
    background-color: red; 
    position: relative; 
    height: 414px; 
    overflow: auto; 
    width: 902px; 
    margin: 0px auto; 
} 

overflow-y: hidden;試過,滾動條消失,但滾動不工作。希望你明白我想要什麼... 另外,我應該使用自動還是滾動?隨着汽車我也看到水平欄。

這裏的jsfiddle:http://jsfiddle.net/sp95S/
謝謝!

+1

你期望發生的?這是正確的行爲。 –

+0

我想隱藏滾動條而不影響滾動。 – youmotherhaveapples

+0

你會如何滾動內容?! –

回答

11

創建一個內部的div:http://jsfiddle.net/sp95S/1/

.div { 
    background-color: red; 
    position: relative; 
    height: 214px; 
    overflow: hidden; 
    width: 452px; 
    margin: 0px auto; 
} 
#inner{ 
    width: 100%; 
    overflow: auto; 
    height: 100%; 
    padding-right: 15px; 
} 
+0

非常聰明的答案! –

3

好像你想擁有的頁面仍然沒有滾動滾動條顯示。

這已經在這裏找到答案了幾次不已:

基本上你可以使用JavaScript(或jQuery的,雖然你不一定需要它) 。在webkit瀏覽器上,有一個隱藏滾動條的功能:

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

但它不適用於Firefox或Internet Explorer或Opera。

+1

這個*可能*在Opera上工作,因爲它現在運行Webkit,但我仍然不會使用它,因爲它不適用於Webkit以外的任何其他應用程序。 –