简体   繁体   English

Rails-使用超赞的字体

[英]Rails - Using Font Awesome

How can I include a fontawesome icon within my button? 如何在我的按钮中包含一个字体惊人的图标?

<%= f.submit 'Post', class: 'btn btn-primary btn-large' %>

I tried 我试过了

<%= f.submit '<i class="icon-ok icon-white"></i>Post'.html_safe, class: 'btn btn-primary btn-large' %>

But it doesn't display the icon properly. 但是它不能正确显示图标。 Any help would be appreciated. 任何帮助,将不胜感激。

If you're using Rails 4 or newer, you can pass a block to the submit method and include your HTML in there. 如果您使用的是Rails 4或更高版本,则可以将一个块传递给Submit方法,并在其中包含HTML。

Try this: 尝试这个:

<%= f.submit class: 'btn btn-primary btn-large' do %>
  <i class="icon-ok icon-white"></i> Post ...
<% end %>

See this GitHub issue for more details: https://github.com/plataformatec/simple_form/issues/745 有关更多详细信息,请参见此GitHub问题: https : //github.com/plataformatec/simple_form/issues/745

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM