1

Currently I am using the following code to display scroll bar:

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

While using this CSS the scroll bars are visible all the time, meaning even when the content inside the div doesn't overflow.

How can I hide them when the content fits within the mentioned height?

RandomUser
  • 1,843
  • 8
  • 33
  • 65
  • 1
    possible duplicate of [CSS hide scroll bar if not needed](http://stackoverflow.com/questions/18716863/css-hide-scroll-bar-if-not-needed) – the6p4c Sep 23 '14 at 04:36

2 Answers2

2

With overflow:auto;. That's all.

Felk
  • 7,720
  • 2
  • 35
  • 65
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;
}