I have an HTML textarea that is of fixed width, but variable height. I would like to set overflow:scroll
and be able to show a vertical scrollbar, but not a horizontal one. I am not able to use overflow:auto
due to other things specific to my situation.
I know there is no way using CSS2 to show only vertical but not horizontal scrollbars. Is there anything I can do with JavaScript to hide the horizontal scrollbar?
To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML. CSS.
1. Set the overflow of the parent div as hidden. 2. Set the overflow of the child div to auto and the width 200% (or anything more than 100%, or more than the width of the parent - so that the scrollbar gets hidden).
Web browsers do not take into account the width of the scrollbar on the side of a page when computing width values, so since we have a page that is longer than a single viewport, part of our page is being rendered behind the vertical scroll bar, causing the browser to display a horizontal scroll bar.
You can use css like this:
overflow-y: scroll; overflow-x: hidden;
Use CSS. It's easier and faster than javascript.
overflow-x: hidden; overflow-y: scroll;
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