scrollbar is disabled when I used the pointer-events: none
css in the text area.
I want the scroll bar to be enalbed to scroll and view whole content but the textarea shouldn’t be editable.
I want to fix this issue only in the css.
I tried many solution but nothing helped me
here i’ve kept my code in the jsfiddle https://jsfiddle.net/a9vxurqo/
kindly help me in this
I tired this solution but didn’t helped me https://codesandbox.io/s/scrollarea-wider-forked-sz9qnf?file=/src/App.js
2
Answers
You can do this in HTML by adding the readonly attribute to the textarea, like this:
I don’t see a way to do this with CSS.
Firstly, why don’t you use
readonly
attribute to a<textarea>
element as this attribute alone effectively create the expected situation (non-editable textarea but users can scroll through the contents).However, since you specifically asked for workaround using CSS only, both
resize: none;
andpointer-events: none;
together prevent editing and resizing while enabling scrolling.The following worked for me: