我想更改 text_field 的大小,但不起作用。
new.html.erb
<div class="row">
<%= form_for(@user) do |f| %>
<%= render 'fields', f: f %>
<%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
<% end %>
</div>
_fields.html.erb
<%= f.label :name %>
<%= f.text_field :name, size: 10 %>
大小:10
不起作用。
最佳答案
这是一个有效的示例,你做错了一些事情,我相信你有一些 css 样式覆盖了你的文本字段:
<%= f.text_field :user, size: 10 %>
如果我删除class
来自提交,地点 </br>
,设置 0 width
在CSS中,现在我看到size
text_field
的
希望你能理解这一点。
关于ruby-on-rails - rails 4 : How to change the size of text_field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24979633/