How can I change the length of a text_field in rails?

klondike-5-3226 picture klondike-5-3226 · Oct 26, 2012 · Viewed 24.8k times · Source

So I have this text field

<%= f.text_field :body, placeholder: "Make an offer ", :maxlength=>"254" %> 

right now it takes up 100% of the width of the box it is in. I want it to take up like 95%. So far I have tried (from other forum posts)

adding :columns => "50" this didn't affect it. I tried putting on an html tag , :html => { :id => "offer_form" } and then putting in my css file

#offer_form { width:50%;} 

this didn't work

any other suggestions?

edit:

I realized that in my css file I have under /forms/

input, textarea, select, .uneditable-input {
  border: 1px solid #bbb;
  width: 98%;
  padding: 10px;
  height: auto !important;
  margin-bottom: 15px;

}

and when i change the width here it works. but it affects all of the forms in the entire app (obviously)(ie they are all 98%). Is there a way that I can id just this field so that I can edit its width independently.

Answer

alex picture alex · Oct 26, 2012

add :size=>"50" option to text_field

<%= f.text_field :body, :size=>"50", placeholder: "Make an offer ", :maxlength=>"254" %>