如何在haml中正确显示字体超棒图标

时间:2023-01-13 15:54:48

I'd like to add the fa-sort icon from font-awesome to a rails application. I'm using bootstrap, and haml, and I can't seem to figure out how to set this up properly. I'd like the sort icon beside this. I tried at the end before the parenthesis closes :class => fa_icon :sort) however, that's not working. then, I tried adding .feature-icon.fa.fa-sort below the table head, and this isn't working properly either. I've added the correct gem, and called it's dependencies in the application.css structure, but for obvious reasons, can't figure this one out, please shed some light. thanks.

我想在rails应用程序中添加来自font-awesome的fa-sort图标。我正在使用bootstrap和haml,我似乎不知道如何正确地设置它。我想要这个旁边的排序图标。我在圆括号结束前尝试了一下:class => fa_icon:sort),但这并不起作用。然后,我尝试添加。feature-icon.fa。fa-sort在桌面下面,这也不能正常工作。我添加了正确的gem,并将其称为应用程序中的依赖项。css的结构,但由于明显的原因,无法理解这一点,请说明。谢谢。

%th= link_to Org.human_attribute_name(:department), params.merge(sort_field: :dept, sort_order: sort_order)

%th= link_to Org.human_attribute_name(:name), params.merge(sort_field: :name, sort_order: sort_order)

2 个解决方案

#1


4  

What if you use a block for the content of the link? I guess you want the icon on the link.

如果您对链接的内容使用块,会怎样?我猜你想要链接上的图标。

%th
  = link_to params.merge(sort_field: :dept, sort_order: sort_order) do
    = Org.human_attribute_name(:department)
    %i.fa.fa-sort

#2


0  

After fontawesome update icons have tags like solid regular brand and light, solid tag exists for every icon, therefore fontawesome haml new usage

在fontawesome更新图标有固定品牌和轻标签后,每个图标都有固定标签,因此fontawesome haml的新用法

%i.fas.fa-sort

% i.fas.fa-sort

some icon names changed, you can find detailde info here

一些图标名称改变,你可以在这里找到详细信息

#1


4  

What if you use a block for the content of the link? I guess you want the icon on the link.

如果您对链接的内容使用块,会怎样?我猜你想要链接上的图标。

%th
  = link_to params.merge(sort_field: :dept, sort_order: sort_order) do
    = Org.human_attribute_name(:department)
    %i.fa.fa-sort

#2


0  

After fontawesome update icons have tags like solid regular brand and light, solid tag exists for every icon, therefore fontawesome haml new usage

在fontawesome更新图标有固定品牌和轻标签后,每个图标都有固定标签,因此fontawesome haml的新用法

%i.fas.fa-sort

% i.fas.fa-sort

some icon names changed, you can find detailde info here

一些图标名称改变,你可以在这里找到详细信息