4

我想使用这里看到的文本输入字段:

http://simple-form-b​​ootstrap.plataformatec.com.br/articles/new

(这是该页面上的第二个文本输入字段。)

我让它在其他 Rails 应用程序中工作,但由于某种原因,在我当前的应用程序中,前置标签和文本输入之间存在几个像素的间隙。我已经使用该--bootstrap选项安装了 simple_form,并验证了 Rails/haml/bootstrap/bootstrap-sass 版本与工作的 rails 应用程序相同。

我不会覆盖我的样式表中的任何相关 css(我已将其全部注释掉以确保)。

任何想法为什么 Bootstrap 没有表现出应有的行为?

4

4 回答 4

4

我真的不知道这里有什么问题,但我有同样的事情。

比较span.add-on标签,我发现他们的标签float: left上有一个。我添加了它,它似乎起到了作用。

我还注意到他们使用的是 twitter 2.01。我使用的是 2.02,所以可能发生了一些变化。

编辑:这搞砸了附加跨度。

.input-prepend .add-on,
.input-append input {
  float: left;
}

是我添加的。感觉不对,但它现在正在工作。希望其他更了解引导程序的人可以提供帮助。

于 2012-04-27T09:15:08.733 回答
2

我没有查看更改以了解原因,但我可以确认它在 2.0.1 中按预期工作,并且在 2.0.2 中有描述的差距。要恢复到旧的正确行为,您可以将 Gemfile 中现有的 bootstrap-sass 行替换为:

gem 'bootstrap-sass', '2.0.1'

并更新您的捆绑包。

于 2012-05-13T19:49:48.287 回答
1

你需要添加这个:content_tag :span, "attribute", :class => "add-on", :style => 'margin-right: -5px;'

于 2012-04-17T10:06:33.767 回答
1

The accepted solution will cause problems if there is an error on the page due to validations. Simple_form actually has a wrapper that will allow you to do this and is much better when handling errors.

<%= f.input :name, :wrapper => :append, :class => "inline" do %>
    <%= f.input_field :name%>
    <%= content_tag :span, "@", :class => "add-on abbn" %>
<% end %>
于 2013-03-02T17:31:54.493 回答