Simple_form文本框非常长

时间:2015-04-30 21:53:12

标签: ruby-on-rails devise simple-form

long inputs

使用simple_form和bootstrap,我无法正确调整输入框的大小。它们的长度不同,过长。我可以在CSS中对它们进行硬编码,但之后它们没有响应。 (我尝试了max-width,但它们最终得到了固定的宽度。)还使用了devise gem进行用户身份验证。

页码:

<div class="booyah-box col-xs-10 col-xs-offset-1">
<h2>Sign up</h2>

<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
  <%= f.error_notification %>

  <div class="form-inputs">
    <%= f.input :email, required: true, autofocus: true %>
    <%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @validatable) %>
    <%= f.input :password_confirmation, required: true %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Sign in", :class => 'btn btn-primary' %>
  </div>
<% end %>

<%= render "devise/shared/links" %>
</div>

1 个答案:

答案 0 :(得分:0)

<div class="row">
<h2>Sign up</h2>
<div class="col-lg-8 col-md-4 col-sm-12 col-xs-12">
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
  <%= f.error_notification %>

  <div class="form-group">
    <%= f.input :email, required: true, autofocus: true, class: "form-control" %>

   // you can add class **col-lg-6** in any input field for maintaining the width

    <%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @validatable), class: "form-control" %>
    <%= f.input :password_confirmation, required: true, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= f.button :submit, "Sign in", :class => 'btn btn-primary' %>
  </div>
<% end %>

<%= render "devise/shared/links" %>
</div>
</div>