RandomUser
RandomUser

Reputation: 1853

Hiding scroll bar of a DIV

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?

Upvotes: 1

Views: 118

Answers (2)

user3567805
user3567805

Reputation:

//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;
}

Upvotes: 2

Felk
Felk

Reputation: 8234

With overflow:auto;. That's all.

Upvotes: 2

Related Questions