我正在尝试修改我的布局,只是为了将link_to添加到我的下拉列表中。
上一个代码:
%li.divider
%li
%a{:href => "#"}
%i.fa.fa-user-profile
Add new user
我这样编辑:
%li.divider
%li
= link_to '<i class="fa fa-user-profile"></i> Add new user'.html_safe, new_user_path
一切看起来都很好,但是fa-user-profile是0px x 0px并且它是不可见的。我做错了什么?
Html输出:
答案 0 :(得分:5)
= link_to new_user_path do
%i.fa.fa-user-profile
Add new user
关于元素不可见性:元素本身应该由FontAwesome的CSS填充,使用font-family
(在类fa
上)和content
(在特定的图标类上)。如果你没有,那就意味着你没有必要的CSS。
如何添加它取决于FontAwesome集成到资产管道中的方式。 font-awesome-sass
' README对此有非常明确的指示,您的解决方案可能会有所不同。
答案 1 :(得分:1)
您可以使用raw()
= link_to raw('<i class="fa fa-user-profile"></i> Add new user'), new_user_path