Making a div vertically scrollable is easy by using CSS overflow property. There are different values in overflow property. For example: overflow:auto; and the axis hiding procedure like overflow-x:hidden; and overflow-y:auto;. It will make vertical and horizontal scrollable bar and the auto will make only vertically scrollable bar.
For vertical scrollable bar use the x and y axis. Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.
Example 1:
<!DOCTYPE html> <html> <head> <style> h1 { color:Green; } div.scroll { margin:4px, 4px; padding:4px; background-color: green; width: 500px; height: 110px; overflow-x: hidden; overflow-y: auto; text-align:justify; } </style> </head> <body> <center> <h1>GeeksforGeeks</h1> <div class="scroll">It is a good platform to learn programming. It is an educational website. Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. Also, any geeks can help other geeks by writing articles on the GeeksforGeeks, publishing articles follow few steps that are Articles that need little modification/improvement from reviewers are published first. To quickly get your articles reviewed, please refer existing articles, their formatting style, coding style, and try to make you are close to them. In case you are a beginner, you may refer Guidelines to write an Article </div> </center> </body> </html> |
Output:

Example 2: In this example use auto in place of overflow-x:hidden; and overflow-y:auto; to make div vertically scrollable.
<!DOCTYPE html> <html> <head> <style> h1 { color:Green; } div.gfg { margin:5px; padding:5px; background-color: green; width: 500px; height: 110px; overflow: auto; text-align:justify; } </style> </head> <body> <center> <h1>GeeksforGeeks</h1> <div class="gfg">It is a good platform to learn programming. It is an educational website. Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. Also, any geeks can help other geeks by writing articles on the GeeksforGeeks, publishing articles follow few steps that are Articles that need little modification/improvement from reviewers are published first. To quickly get your articles reviewed, please refer existing articles, their formatting style, coding style, and try to make you are close to them. In case you are a beginner, you may refer Guidelines to write an Article </div> </center> </body> </html> |
Output:

Recommended Posts:
- Make a div horizontally scrollable using CSS
- How to make an image center-aligned (vertically & horizontally) inside a bigger div using CSS?
- How to overlay one div over another div using CSS
- How to vertically align text inside a flexbox using CSS?
- How to Vertically Align Text Next to an Image using CSS ?
- How to copy the content of a div into another div using jQuery ?
- How to vertically center text with CSS?
- How to align objects vertically when working with grids in CSS ?
- How to center a div within another div?
- How to clear all div's content inside a parent div ?
- How to vertically flip a text canvas using Fabric.js ?
- How to make horizontal scrollable in a bootstrap row?
- How to fixed one column and scrollable other column or columns in Bootstrap ?
- How to make vertical scrollable rows in bootstrap?
- How to get card vertically centered between search bar and bottom of the viewport?
- How to vertically and horizontally align flexbox to center ?
- How to align content of a div to the bottom using CSS ?
- How to horizontally center a div using CSS?
- How to auto-resize an image to fit a div container using CSS?
- How to give a div tag 100% height of the browser window using CSS
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ankit bajpai


