ruby-on-rails - rails 4 : How to change the size of text_field

标签 ruby-on-rails ruby-on-rails-4

我想更改 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 %>

enter image description here enter image description here enter image description here enter image description here

如果我删除class来自提交,地点 </br> ,设置 0 width在CSS中,现在我看到size text_field

enter image description here

enter image description here

希望你能理解这一点。

关于ruby-on-rails - rails 4 : How to change the size of text_field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24979633/

相关文章:

ruby-on-rails - Heroku 上生产中的 Rails 5 应用程序正在使用 GET 方法调用注销

ruby-on-rails - Rails 邮件发送 : getaddrinfo: Name or service not known

ruby-on-rails - 如何在 rails 4 中通过 AJAX 向表单添加附加字段?

css - 预编译 Assets 后,Rails 不编译开发中的样式表

ruby-on-rails - 类(class)开头的 '::' 如何影响范围 (ruby/rails)?

ruby-on-rails - Puma 无法在 jRuby 上启动,错误为 : The signal USR1 is in use by the JVM and will not work correctly on this platform

ruby-on-rails - 如何使用 Rspec 和 Capybara 测试重定向

ruby-on-rails - 将/profiles/1/edit/details 重写为/me/profile/details 的最佳方法?

ruby-on-rails - NoMethodError 未定义方法 ` ' 为 nil :NilClass

ruby-on-rails - 了解 Rails 4 中的 after_update 回调