My designer just gave me the design with text areas with styled resize grabber. The question is: Can I style it or not ?
height = 'auto'; to this. style. height = '0px'; and add a min-height to prevent the initial state from actually going to 0, scrollHeight will correctly return one row of height when appropriate.
A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier). The size of a text area is specified by the <cols> and <rows> attributes (or with CSS).
WebKit provides the pseudo-element ::-webkit-resizer
for the resize control it automatically adds to the bottom right of textarea
elements.
It can be hidden by applying display: none
or -webkit-appearance: none
:
::-webkit-resizer { display: none; }
<textarea></textarea>
This displays as follows in Chrome 26 on OS X:
Note: Adding display: none
to ::-webkit-resizer
doesn’t actually prevent the user from resizing the textarea, it just hides the control. If you want to disable resizing, set the resize
CSS property to none
. This also hides the control and has the added benefit of working in all browsers that support resizing textareas.
The ::-webkit-resizer
pseudo-element also allows for some basic styling. If you thought the resize control could use significantly more color you could add this:
::-webkit-resizer { border: 2px solid black; background: red; box-shadow: 0 0 5px 5px blue; outline: 2px solid yellow; }
<textarea></textarea>
This displays as follows in Chrome 26 on OS X:
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