2014-09-23 171 views
1

目前我使用下面的代碼來顯示滾動條:隱藏滾動條

div.productsTree{ 
    height:300px; 
    overflow:scroll; 
} 

在使用這個CSS的滾動條是可見的所有的時間,這意味着,即使裏面的內容div不溢出。

如何在內容符合上述高度時隱藏它們?

+1

可能重複[CSS隱藏滾動條,如果不需要](http://stackoverflow.com/questions/18716863/css-hide-scroll-bar-if-not-needed) – The6P4C 2014-09-23 04:36:34

回答

2

With overflow:auto;。就這樣。

2
//Both x,y axis scroll 
div.productsTree{ 
    height:300px; 
    overflow:auto; 
} 

//only x axis scroll 
div.productsTree{ 
    height:300px; 
    overflow:auto; 
    overflow-y: hidden; 
} 

//only y axis scroll 
div.productsTree{ 
    height:300px; 
    overflow:auto; 
    overflow-x: hidden; 
}