Remove scrollbars from textarea
Asked Answered
B

9

119

Following up to my previous question (Add a scrollbar to a <textarea>) on how to always see the scrollbar in a <textarea>, I am now wondering how you would set it so that there is no scrollbar in the <textarea>, even when the text overflows. To scroll down with this, you would use the arrow keys or the mouse to navigate through the text.

How can I do this?

Birdie answered 17/10, 2013 at 11:1 Comment(1)
Did you try <textarea style="overflow:hidden"></textarea>?Blisse
G
186

Try the following, not sure which will work for all browsers or the browser you are working with, but it would be best to try all:

<textarea style="overflow:auto"></textarea>

Or

<textarea style="overflow:hidden"></textarea>

...As suggested above

You can also try adding this, I never used it before, just saw it posted on a site today:

<textarea style="resize:none"></textarea>

This last option would remove the ability to resize the textarea. You can find more information on the CSS resize property here

Gustave answered 17/10, 2013 at 11:14 Comment(4)
textarea_element.style.overflow = "hidden"; (worked in Firefox 44.0)Titanesque
This approach hides scrollbar, but if your content is big it doesn't scrolls it anymore.Sawhorse
Combine with https://mcmap.net/q/188801/-growing-textarea-in-blazorSmallminded
textarea { overflow:hidden; } worked for me in cssParhelion
B
25

style="overflow: hidden" and style="resize: none" were the ones that did the trick.

Beechnut answered 20/3, 2014 at 18:19 Comment(1)
how exactly is this not an answer?Sula
C
20

Give a class for eg: scroll to the textarea tag. And in the css add this property -

.scroll::-webkit-scrollbar {
   display: none;
 }
<textarea class='scroll'></textarea>

It worked for without missing the scroll part

Cowley answered 16/5, 2016 at 10:35 Comment(2)
Perfect, you can scroll but scrollbars don't show up. Exactly what I needed. Thanks.Polynomial
This is not cross browser compliant, e.g. it will not in Firefox.Annual
S
10

For MS IE 10 you'll probably find you need to do the following:

-ms-overflow-style: none

See the following:

https://msdn.microsoft.com/en-us/library/hh771902(v=vs.85).aspx

Selfdeception answered 23/6, 2015 at 19:31 Comment(1)
This. Nothing else seems to work for IE10. Great stuff.Poise
M
10

Hide scroll bar, but while still being able to scroll using CSS

To hide the scrollbar use -webkit- because it is supported by major browsers (Google Chrome, Safari or newer versions of Opera). There are many other options for the other browsers which are listed below:

    -webkit- (Chrome, Safari, newer versions of Opera):
    .element::-webkit-scrollbar { width: 0 !important }
    -moz- (Firefox):
    .element { overflow: -moz-scrollbars-none; }
    -ms- (Internet Explorer +10):
    .element { -ms-overflow-style: none; }

ref: https://www.geeksforgeeks.org/hide-scroll-bar-but-while-still-being-able-to-scroll-using-css/

Martinmartina answered 3/12, 2019 at 7:38 Comment(2)
Doesn't work in FFSupplicate
.scrollable {overflow: hidden;} .scrollable::-webkit-scrollbar {display: none;} works for chrome and FF.Supplicate
S
1

The solutions for just not displaying the scrollbar (instead of completely hiding overflow) mentioned in the other answers (see ::-webkit-scrollbar) work fine except for Firefox. Also the "-moz-" specific solutions mentioned are not working in Firefox for me.

Instead use:

scrollbar-width: none;

for Firefox!

Scuttle answered 21/9, 2022 at 15:53 Comment(0)
C
0

I was able to get rid of my scroll bar on the body of text by removing my max-height attribute of my class.

Cowberry answered 18/6, 2019 at 1:46 Comment(0)
K
0

Hide scroll bar for Mozilla.

  overflow: -moz-hidden-unscrollable;
Kosygin answered 2/1, 2021 at 11:57 Comment(1)
This is not working for me in FireFox, the answer from @Scuttle seems to work.Sarsenet
L
0

like some others mentioned, hiding the scrollbars without affecting scrolling I think is the intended behavior: https://blog.logrocket.com/hide-scrollbar-without-impacting-scrolling-css

Lamonica answered 10/2, 2023 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.