multiple font awesome icons as rails link

浪尽此生 提交于 2019-12-11 15:47:47

问题


I have the following font-awesome line that is a clickable link

%p.add_stuff= link_to(content_tag(:i, nil, class: "fa fa-plus"), new_journey_trip_path(@journey))

In addition to fa-plus, I'd like to add another font-awesome plus icon (so it appears something like + + ). How do I achieve this?

I've tried calling fa-plus two times, as well as making two content_tag, but neither seems to work.


回答1:


with link_to, you can nest the contents

%p.add_stuff
  = link_to new(journey_trip_path(@journey)) do
    = content_tag(:i, nil, class: "fa fa-plus")
    = content_tag(:i, nil, class: "fa fa-plus")

or

%p.add_stuff
   = link_to new(journey_trip_path(@journey)) do
     %i.fa.fa-plus
     %i.fa.fa-plus

or, you may have the fa_icon method available...

%p.add_stuff
  = link_to new(journey_trip_path(@journey)) do
    = fa_icon('plus')
    = fa_icon('plus')



回答2:


Have you tried something like this?

%p.add_stuff= link_to(new_journey_trip_path(@journey)) do
  %i.fa.fa-plus
  %i.fa.fa-plus

You can also remove whitespace if needed:

%p.add_stuff= link_to(new_journey_trip_path(@journey)) do
  %i.fa.fa-plus>
  %i.fa.fa-plus>


来源:https://stackoverflow.com/questions/31326684/multiple-font-awesome-icons-as-rails-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!