I have a page I'm working on that encompasses a vertical drop-down menu. However, when the menu drops down, it pushes the text below it downwards and off the page. This is expected, but this enables the scroll bar on the side of the page. I was wondering it there was a way to get rid of this. In other words, it shouldn't just not scroll, but never even offer the option to scroll.
Thanks!
To hide the vertical scrollbar and prevent vertical scrolling, use overflow-y: hidden like so: HTML.
Use overflow: hidden; on the element you want to hide the scrollbar on.
Disabling scroll with only CSS. There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.
If you want no scrollbar to appear and no scrolling whatsoever to occur, in the CSS for the div
in which you contain said dropdown use
overflow: hidden;
This will cut off any 'additional content' though; see an example here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With