How to add scroll to the current div after overflowing?

Viewed 55

How to add scroll to a block element?

I've used overflow-y: scroll, but it immediately creates a scrollbar. I want scrolling after my div has reached a specific height.

2 Answers

You should use overflow-y: auto to get scroll after fulfilling the height of an element.

auto Depends on the user agent. If content fits inside the padding box, it looks the same as visible, but still establishes a new block-formatting context. Desktop browsers provide scrollbars if content overflows. - MDN

Whereas scroll Content is clipped if necessary to fit vertically in the padding box. Browsers display scrollbars whether or not any content is actually clipped. (This prevents scrollbars from appearing or disappearing when the content changes.) Printers may still print overflowing content. - MDN

First you have to give a proper height and width of your content area where you have to overflow.
You have a <div> which has more content than your area than you can use overflow tag with scroll.....

width: #;
height: #;
overflow: scroll;
Related