-1

I want to always show the vertical scroll bar on the div irrespective of the height.

.myclass {
  overflow-y: scroll;
}
<div class="myclass">
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
  survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
  software like Aldus PageMaker including versions of Lorem Ipsum.
</div>

But the scroll bar is disabled. Here is my JSFiddle: https://jsfiddle.net/9jgp5ncm/

How can I always show the vertical scroll bar. Please help.

Debsmita Paul
  • 1,442
  • 9
  • 22
  • hope this is help you - https://stackoverflow.com/questions/7492062/css-overflow-scroll-always-show-vertical-scroll-bar – s.kuznetsov Sep 03 '20 at 09:01
  • I think you have to add some height value to the wrapper. It can be in px, vw, vh or percentage otherwise the whole container is going to take the total height of the text content and there will be nothing to scroll. – Debsmita Paul Sep 03 '20 at 09:01
  • @Paul: I want to always show the vertical scroll bar. Adding height will show scroll bar only when overflow. – Khaja Moinuddin Sep 03 '20 at 09:04
  • _“But the scroll bar is disabled”_ - of course it is. What else would it be, if there _is_ nothing to scroll? – CBroe Sep 03 '20 at 09:04
  • @CBroe: https://jsfiddle.net/9jgp5ncm/, here we have lot of text, sill it doing the same – Khaja Moinuddin Sep 03 '20 at 09:10
  • Yes, of course it does - because there is no limit on the height of the element, so it will grow to be as high as the content requires. And that in turn again means, that there _is nothing to scroll_. – CBroe Sep 03 '20 at 09:14

2 Answers2

0

You try to change browser behavior what is on the native scroll-bars not possible.

You can add an inner-div in your myClass diff and make it 5 pixel bigger as your outer diff so the scroll element is activated.

Or use one of the thousands library for custom scrollers.

But honestly I have no clue why you want to change it for your project.

0

You should add height to your container:

.myclass
{
  overflow-y: scroll;
  height: 200px;
}
d219
  • 2,707
  • 5
  • 31
  • 36
Abhi Sharma
  • 61
  • 1
  • 7