我正在尝试将搜索框放在中心,就像上面的链接一样,但是添加:align => “中心”显然是错的......这就是我所拥有的......
<h2 align="center"><%= link_to "List by Topic", topics_path %></h2>
<h2 align="center"><%= link_to "List by Organisation", hospitals_path %></h2>
<h2 align="center"><%= link_to "List by Country", countries_path %></h2>
<h2 align="center"><%= link_to "List by Specialty", specialties_path %></h2>
<%= form_tag guidelines_path, :class => 'navbar-search',:onSubmit=>"clearText(this)",:method => :get do %>
<%= text_field_tag :search, params[:search], :class => 'search-query input-medium', :placeholder=>"Search", :ONFOCUS=>"clearDefault(this)" %>
<% end %>
答案 0 :(得分:0)
我不建议执行"align"
属性,因为已经从HTML标准中弃用了这些属性 - 而是使用CSS来对齐文本。
话虽如此,如果你在父元素上放置一个text-align: center;
属性,它应该对齐所有不是全宽度的子节点并接受对齐。
修改强>
这是我曾经“匹配”的CSS(假设我匹配你所得到的,因为我看不到你的结果)。
h2 {
text-align: center;
}
.search-wrapper {
text-align: center;
}
form.navbar-search {
float: none;
}
你可以在这里查看小提琴:http://jsfiddle.net/Cx2rV/