开发者

Chrome : make non resizable textareas

开发者 https://www.devze.com 2022-12-17 23:26 出处:网络
By default, Chrome makes my textareas resizable. I wish to control this开发者_运维技巧 and either make them only vertically resizable, or not at all.

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 ?


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;
     }


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.


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消