【问题标题】:Rails and Font Awesome not working? Icons not displayingRails 和 Font Awesome 不起作用?图标不显示
【发布时间】:2023-04-09 03:35:01
【问题描述】:

我已在我的 -Head- 应用布局中添加了 Bootstrap 和 Font Awesome 的链接,但 FA 图标未显示。它们显示在 DOM 中,但作为空白项。我都试过了,会是什么?

 <head>
    <title>RailsTaskManager</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css Tasks:/font-awesome.min.css“>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
  </head>

Index.html.erb,-ul-中的图标

<ul>

  <% @tasks.each do |task| %>
  <li>
    <input type="checkbox" id="completed?" name="completed?" <%= task.completed ? "checked" : "" %>>
    <%= link_to("#{task.title}", "/tasks/#{task.id}") %>
    <!-- delete -->
    <%= link_to task_path(task),
                method: :delete,
                data: { confirm: "Are you sure?" } do  %>
      <!-- not displaying -->
      <i class="fa fa-trash-o" aria-hidden="true">Delete this task</i>
    <% end %>
  </li>
  <% end %>

</ul>

【问题讨论】:

    标签: html css ruby-on-rails fonts


    【解决方案1】:

    这是我在项目中如何使用它的一个可行示例

    <%= link_to "http://www.link.com/" do %>
      <i class="fa fa-link"></i>
    <% end %>
    

    您是否尝试将其添加到您的 Gemfile 中?

    gem "font-awesome-rails"
    

    然后运行

    bundle install
    

    在您的 application.css 中,包含 css 文件:

    /*
     *= require font-awesome
     */
    

    如果之前正在运行,则重新启动您的网络服务器。

    这里是documentation 和一些helpers,可能会有所帮助。

    如果您有任何问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 2022-01-18
      • 1970-01-01
      • 2020-08-01
      • 2017-12-25
      • 1970-01-01
      • 1970-01-01
      • 2013-05-10
      • 2016-12-12
      • 1970-01-01
      相关资源
      最近更新 更多