2014-09-23 189 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; 
}