0

我想更改表单的外观。对于 html,我会用 css 更改输入标签。在 Rails 中,我试图将 div 添加到表单中,但是没有成功。如何使它正确?

<%= search_form_for @search do |f| %>

<p>
  <%= f.label :degree_cont, "...by degree (e.g. bachelor)" %>
  <%= f.text_field :degree_cont, size: 15 %>
</p>

<p class="button"><%= f.submit "Search" %></p>
<% end %>   
4

2 回答 2

0

如果您是 css 新手,我建议您查看 Twitter bootstrap。

尝试添加gem bootstrap-sass到您的Gemfile. 然后转到http://twitter.github.io/bootstrap/base-css.html#forms。我猜这.form-search门课就是你要找的。

您可以使用与此类似的代码来使用此 css 类创建表单:

<%= form_for(@search, :html => { :class => 'form-search' }) do |f| %>
...
于 2013-05-03T18:21:00.860 回答
0

您可以在 rails 的搜索表单中添加一个类,然后在 CSS 中对其进行样式设置,而不是添加 div。像这样:

<%= search_form_for @search, :html => { :class => "your-class-here" } do |f| %>

于 2013-05-03T18:36:17.847 回答