82

By default, Chrome makes my textareas resizable. I wish to control this and either make them only vertically resizable, or not at all.

How can I achieve this ?

glmxndr
  • 45,516
  • 29
  • 93
  • 118
  • possible duplicate of [How to disable resizable property of textarea?](http://stackoverflow.com/questions/5235142/how-to-disable-resizable-property-of-textarea) – abhishah901 Jun 07 '15 at 10:07

3 Answers3

149

Rails generate standard textarea tag, but Safari/Chrome (Webkit) display all (not only Rails :) textareas as resizable.

Its apperance may be disabled by CSS

textarea {
    resize: none;
    }

Or, if need only vertical resize:

textarea {
     resize: vertical;
     }
glmxndr
  • 45,516
  • 29
  • 93
  • 118
ingeniarius
  • 1,526
  • 1
  • 9
  • 3
5

Set max-width to make them only vertically resizable, or set max-height and max-width to stop all resizing.

However, be aware that breaking user expectations about how their browser treats controls tends to create a lot of user frustration.

jball
  • 24,791
  • 9
  • 70
  • 92
-3

you can set the column and rows like

<%= text_area :object, :attribute, :rows => '10', :cols => '100' %> 
#=> <textarea cols="100" rows="10" id="object_attribute" name="object[attribute]">
#      #{@object.attribute}
#   </textarea>

or specify the size like

<%= text_area :object, :attribute, :size => "10x100" %> 
#=> <textarea cols="10" rows="100" id="object_attribute" name="object[attribute]">
#      #{@object.attribute}
#   </textarea>
nas
  • 3,676
  • 19
  • 19