Praveen Prasad
Praveen Prasad

Reputation: 32107

Scrollbar on demand in CSS (overflow property)

I am creating a <div> with a class someClass

.someClass {
   overflow:scroll
   /*other props*/
}

The problem is that the scrollbars are always visible even when the data is not overflowing. I want the scrollbars to be visible only when data actually overflows.

Upvotes: 2

Views: 1663

Answers (2)

Tor Valamo
Tor Valamo

Reputation: 33749

overflow:auto; should do it. You need to set a width (for horizontal scrolling) and height (vertical) for that to pop out scrollbars at the right time though.

Upvotes: 9

Daniel Vassallo
Daniel Vassallo

Reputation: 344271

Use overflow: auto;

Upvotes: 3

Related Questions