前提
- 本のタイトルと感想を投稿できるアプリケーションを作成中です
- CSSのフォルダはいじらずにすべてHTMLで処理(カリキュラムの課題要件のため)
実現したいこと
- Fontawesomeを使ってアイコンを表示させたい
- アイコンもリンクに含ませたい
発生している問題
- アイコンが表示されているものもあればなぜか表示されていないものもある
- アイコンとテキストを色も白で統一したいが、Homeのアイコンのみ白になっている。
- Log out、About、Login、Signupに至ってはテキストは出ているものの、アイコンの表示すらされていません(本当になぜ...?)
- Homeアイコン以外は黒、テキストも青いままなので白に変えたいです
該当のソースコード
ruby
1<!DOCTYPE html> 2<html> 3 <head> 4 <title>Bookers2Ver2</title> 5 <%= csrf_meta_tags %> 6 <%= csp_meta_tag %> 7 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 8 <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 9 <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> 10 </head> 11 <body> 12 <header> 13 <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> 14 <div class="container"> 15 <a class="navbar-brand" href="https://bookers-level2.herokuapp.com"> 16 <span>Bookers</span> 17 </a> 18 <!-- ハンバーガーアイコン --> 19 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" 20 aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation"> 21 <span class="navbar-toggler-icon"></span> 22 </button> 23 24 <div class="collapse navbar-collapse" id="navbarNavDropdown"> 25 <ul class="navbar-nav ml-auto fa-ul"> 26 <% if user_signed_in? %> 27 <li> 28 <i class="fas fa-home"></i> 29 <%= link_to 'Home', user_path(current_user.id) %> 30 </li> 31 <li> 32 <i class="fas fa-users"></i> 33 <%= link_to 'Users', users_path %> 34 </li> 35 <li> 36 <i class="fas fa-book-open"></i> 37 <%= link_to 'Books', books_path %> 38 </li> 39 <li> 40 <i class="fas fa-sign-out-alt"></i> 41 <%= link_to "Log out", destroy_user_session_path %> 42 </li> 43 <% else %> 44 <li> 45 <i class="fas fa-home"></i> 46 <%= link_to "Home", root_path %> 47 </li> 48 <li> 49 <i class="fas fa-link"></i> 50 <%= link_to 'About', home_about_path %> 51 </li> 52 <li> 53 <i class="fas fa-user-plus"></i> 54 <%= link_to "Sign up", new_user_registration_path %> 55 </li> 56 <li> 57 <i class="fas fa-sign-in-alt"></i> 58 <%= link_to "Log in", new_user_session_path %> 59 </li> 60 <% end %> 61 </ul> 62 </div> 63 </div> 64 </nav> 65 </header> 66 <main class="mb-auto"> 67 <%= flash[:notice] %> 68 <%= yield %> 69 </main> 70 71 <footer> 72 <p id="notice"></p> 73 <div class="container mt-5"> 74 <div class="row"> 75 <div class="mx-auto"> 76 <p>CopyRight Infratop.inc</p> 77 </div> 78 </div> 79 </div> 80 </footer> 81 </body> 82</html> 83
試したこと
いろいろ調べてSpanタグで囲ってみたり、 以下のように記述もしてみたのですがだめでした。
ruby
1<i class="fas fa-home" style="color:white;"></i>
補足情報(FW/ツールのバージョンなど)
Fontawesomeは5.15.4を使用
(ただ、Bookのアイコンが本を開いているものなのに表示されているのは閉じているものであったりしているので設定がうまくいってない可能性もあるかもしれません)
念のため、js,scssも記載
(カリキュラム通りに行っているのでおそらく問題ないとは思うのですが...)
application.scss
1@import '~bootstrap/scss/bootstrap'; 2@import '~@fortawesome/fontawesome-free/scss/fontawesome';
application.js
1import Rails from "@rails/ujs" 2import Turbolinks from "turbolinks" 3import * as ActiveStorage from "@rails/activestorage" 4import "channels" 5 6import "jquery"; 7import "popper.js"; 8import "bootstrap"; 9import "../stylesheets/application" 10import '@fortawesome/fontawesome-free/js/all' 11 12Rails.start() 13Turbolinks.start() 14ActiveStorage.start()
以下追記1
cloud9
1=> Booting Puma 2=> Rails 6.1.6.1 application starting in development 3=> Run `bin/rails server --help` for more startup options 4Puma starting in single mode... 5* Puma version: 5.6.4 (ruby 3.1.2-p20) ("Birdie's Version") 6* Min threads: 5 7* Max threads: 5 8* Environment: development 9* PID: 7626 10* Listening on http://127.0.0.1:8080 11* Listening on http://[::1]:8080 12Use Ctrl-C to stop 13Started GET "/" for 106.150.140.40 at 2022-08-26 00:29:02 +0000 14Cannot render console from 106.150.140.40! Allowed networks: 127.0.0.0/127.255.255.255, ::1 15 (1.4ms) SELECT sqlite_version(*) 16 (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 17Processing by HomesController#top as HTML 18 Rendering layout layouts/application.html.erb 19 Rendering homes/top.html.erb within layouts/application 20 Rendered homes/top.html.erb within layouts/application (Duration: 4.6ms | Allocations: 621) 21[Webpacker] Everything's up-to-date. Nothing to do 22 Rendered layout layouts/application.html.erb (Duration: 22.9ms | Allocations: 3551) 23Completed 200 OK in 48ms (Views: 30.6ms | ActiveRecord: 0.0ms | Allocations: 7521) 24 25 26Started GET "/" for 106.150.140.40 at 2022-08-26 00:29:05 +0000 27Cannot render console from 106.150.140.40! Allowed networks: 127.0.0.0/127.255.255.255, ::1 28Processing by HomesController#top as HTML 29 Rendering layout layouts/application.html.erb 30 Rendering homes/top.html.erb within layouts/application 31 Rendered homes/top.html.erb within layouts/application (Duration: 0.7ms | Allocations: 341) 32[Webpacker] Everything's up-to-date. Nothing to do 33 Rendered layout layouts/application.html.erb (Duration: 6.8ms | Allocations: 2853) 34Completed 200 OK in 11ms (Views: 10.1ms | ActiveRecord: 0.0ms | Allocations: 4298) 35 36 37Started GET "/home/about" for 106.150.140.40 at 2022-08-26 00:29:46 +0000 38Cannot render console from 106.150.140.40! Allowed networks: 127.0.0.0/127.255.255.255, ::1 39Processing by HomesController#about as HTML 40 Rendering layout layouts/application.html.erb 41 Rendering homes/about.html.erb within layouts/application 42 Rendered homes/about.html.erb within layouts/application (Duration: 0.9ms | Allocations: 129) 43[Webpacker] Everything's up-to-date. Nothing to do 44 Rendered layout layouts/application.html.erb (Duration: 6.3ms | Allocations: 2120) 45Completed 200 OK in 13ms (Views: 12.7ms | ActiveRecord: 0.0ms | Allocations: 2777) 46 47 48Started GET "/users/sign_up" for 106.150.140.40 at 2022-08-26 00:30:30 +0000 49Cannot render console from 106.150.140.40! Allowed networks: 127.0.0.0/127.255.255.255, ::1 50Processing by Devise::RegistrationsController#new as HTML 51 Rendering layout layouts/application.html.erb 52 Rendering devise/registrations/new.html.erb within layouts/application 53 Rendered devise/shared/_error_messages.html.erb (Duration: 1.1ms | Allocations: 275) 54 Rendered devise/shared/_links.html.erb (Duration: 1.7ms | Allocations: 610) 55 Rendered devise/registrations/new.html.erb within layouts/application (Duration: 22.3ms | Allocations: 5658) 56[Webpacker] Everything's up-to-date. Nothing to do 57 Rendered layout layouts/application.html.erb (Duration: 27.4ms | Allocations: 7672) 58Completed 200 OK in 42ms (Views: 31.3ms | ActiveRecord: 0.6ms | Allocations: 15518) 59 60 61^C- Gracefully stopping, waiting for requests to finish 62=== puma shutdown: 2022-08-26 00:30:47 +0000 === 63- Goodbye! 64Exiting
追記2(コンソール上のエラー)
コAutofocus processing was blocked because a document already has a focused element. DevTools failed to load source map: Could not load content for https://41bba7c5241c4e8a8ab9eab04d92f21a.vfs.cloud9.ap-northeast-1.amazonaws.com/packs/js/application-de10aaf691dd43e39fc5.js.map: HTTP error: status code 503, net::ERR_HTTP_RESPONSE_CODE_FAILURE
かれこれ5時間以上は試行錯誤して詰まっているので切実に困っています...ご協力お願いいたします。
回答1件
あなたの回答
tips
プレビュー