Twitter bootstrap 如何使用简单表单和引导将提交按钮放置在与输入相同的行上?

Twitter bootstrap 如何使用简单表单和引导将提交按钮放置在与输入相同的行上?,twitter-bootstrap,simple-form,Twitter Bootstrap,Simple Form,使用简单的表单和引导,我希望下面的内容在线显示,而不是在输入选择下面的submit按钮 <%= simple_form_for :select_rollout, :html => {:class => "form-inline"}, do |f| %> <%= f.input :rollout_id, collection: @rollout_options, :label => false %> <%= f.button :submit,

使用简单的表单和引导,我希望下面的内容在线显示,而不是在输入选择下面的submit按钮

<%= simple_form_for :select_rollout, :html => {:class => "form-inline"}, do |f| %>
  <%= f.input :rollout_id, collection: @rollout_options, :label => false %>
  <%= f.button :submit, "Apply" %>
<% end %>
{:class=>“forminline”},do | f |%>
假%>
以下解决方案仅适用于输入(提交按钮在输入的div外部呈现):


尝试将
向左拉
向右拉
类添加到元素中。这将为对象添加
float:left
float:right
属性

但如果float不适合您,请创建自己的类,称为inline,如下所示:


.内联{
显示:内联;
}

或(取决于站点的实施)


.内联{
显示:内联块;
}


并将
inline
类添加到您的对象中。

要解决这个问题,我需要在输入块内部使用input\u字段,并使用块包装器上的inline form样式:

<%= f.input :rollout_id, :label => false, wrapper_html: {class: "form-inline"} do %>
  <%= f.input_field :rollout_id, collection: @rollout_options, :label => false %>
  <%= f.button :submit, "Apply", :class => "btn-primary" %>
<% end %>
false,wrapper\u html:{class:“表单内联”}do%>
假%>
“btn主要”%>

希望这对其他人有所帮助。

对于以后阅读本文的任何人,我通常只需将输入内容打包并提交到flexbox中即可。 您可以在之后提供您希望每个元素的外观样式(即:给定表单组宽度:100%)

<%= simple_form_for :select_rollout, :html => {:class => "form-inline"}, do |f| %>
  <div class="flexbox-class">
    <%= f.input :rollout_id, collection: @rollout_options, :label => false %>
    <%= f.button :submit, "Apply" %>
  </div>
<% end %>


.flexbox-class {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  .form-group {
    width: 100%;
  }
  .btn-primary {
    margin-bottom: 16px
  }
}
{:class=>“forminline”},do | f |%>
假%>
.flexbox类{
显示器:flex;
证明内容:之间的空间;
对齐项目:柔性端;
.表格组{
宽度:100%;
}
.btn主要{
边际下限:16px
}
}

谢谢你的建议,我试过了,但没有效果。请参阅下面的解决方案。
<%= simple_form_for :select_rollout, :html => {:class => "form-inline"}, do |f| %>
  <div class="flexbox-class">
    <%= f.input :rollout_id, collection: @rollout_options, :label => false %>
    <%= f.button :submit, "Apply" %>
  </div>
<% end %>


.flexbox-class {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  .form-group {
    width: 100%;
  }
  .btn-primary {
    margin-bottom: 16px
  }
}