環境
- Visual Studio Code Version: 1.55.0
- ブラウザ google chrome
- Rails 5.2.5
- macOS Catalina バージョン10.15.7
- gem 'haml-rails'
##エラーに至った経緯
さっきまでcssが動いていたのですが共通部分(ヘッダーの共通部分レイアウト)をapplication.scssにヘッダー部分のコードを移したのですがそこからcssが反応しなくなりました。検証しても何も反映されていない模様。
検証した時のコードのスクショ
検索では「CSS 反応しない」等で調べていたのですがそれらを試したものを一覧にしておきます。
- 不注意によるもの(.がない、{が足りないや余分)
- スーパーリロード
- githubにpushした時のコードをコピー&ペーストした。理由はこのコードであれば確実にcssは反映されていたから。
apllication.html.haml
1%html 2 %head 3 %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ 4 %title Connect Student 5 = csrf_meta_tags 6 = csp_meta_tag 7 = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' 8 = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' 9 %body 10 = yield 11
html
1.home 2 .top-block 3 %img.home__image{:alt => "notdecade", :src => "https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/connecting-and-sharing-royalty-free-image-1579168818.jpg"} 4 %h1.welcome-to-japan Welcome to Japan 5 %h1.international international 6 %h1.student students 7 %header#login-header.l-login-header 8 %a.transfer-mypage{:href => "/"} 9 %img.logo-mark{:alt => "logo", :src => "https://i.gzn.jp/img/2018/01/15/google-gorilla-ban/00.jpg"} 10 %nav#navigation.navigation 11 12 %ul.nav-list 13 %li.top-page TOP 14 %li.registraition NEW 15 %li.my-page ME 16 %li.login-page LOGIN
css
1.l-login-header { 2 width: 90%; 3 height: 100px; 4 position: fixed; 5 left: 50%; 6 transform: translateX(-50%); 7 top: 30px; 8 background-color: #FF9872; 9 background: rgba(7, 7, 7, 0.7); 10 11 .transfer-mypage { 12 display: block; 13 position: absolute; 14 top: 25px; 15 left: 10px; 16 17 .logo-mark { 18 width: 202px; 19 height: 50px; 20 margin-left: 45px; 21 } 22 } 23 24 .navigation { 25 height: 100px; 26 27 .nav-list { 28 font-size: 30px; 29 display: flex; 30 color: white; 31 list-style: none; 32 justify-content: flex-end; 33 margin-right: 2%; 34 width: 900px; 35 margin-left: 40%; 36 height: 100px; 37 justify-content: space-between; 38 margin-top: 25px; 39 40 .top-page { 41 color: #009d80; 42 position: relative; 43 display: block; 44 height: 100px; 45 } 46 47 .registraition { 48 color: #009d80; 49 position: relative; 50 display: block; 51 } 52 53 .my-page { 54 color: #009d80; 55 position: relative; 56 display: block; 57 } 58 59 .login-page { 60 color: #009d80; 61 position: relative; 62 display: block; 63 } 64 } 65 } 66 } 67 68 }
gemfile
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.5.1' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 5.2.5' 8# Use sqlite3 as the database for Active Record 9gem 'sqlite3' 10# Use Puma as the app server 11gem 'puma', '~> 3.11' 12# Use SCSS for stylesheets 13gem 'sass-rails', '~> 5.0' 14# Use Uglifier as compressor for JavaScript assets 15gem 'uglifier', '>= 1.3.0' 16# See https://github.com/rails/execjs#readme for more supported runtimes 17# gem 'mini_racer', platforms: :ruby 18 19# Use CoffeeScript for .coffee assets and views 20gem 'coffee-rails', '~> 4.2' 21# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 22gem 'turbolinks', '~> 5' 23# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 24gem 'jbuilder', '~> 2.5' 25# Use Redis adapter to run Action Cable in production 26# gem 'redis', '~> 4.0' 27# Use ActiveModel has_secure_password 28# gem 'bcrypt', '~> 3.1.7' 29 30# Use ActiveStorage variant 31# gem 'mini_magick', '~> 4.8' 32 33# Use Capistrano for deployment 34# gem 'capistrano-rails', group: :development 35 36# Reduces boot times through caching; required in config/boot.rb 37gem 'bootsnap', '>= 1.1.0', require: false 38 39group :development, :test do 40 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 41 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 42end 43 44group :development do 45 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 46 gem 'web-console', '>= 3.3.0' 47 gem 'listen', '>= 3.0.5', '< 3.2' 48 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 49 gem 'spring' 50 gem 'spring-watcher-listen', '~> 2.0.0' 51end 52 53group :test do 54 # Adds support for Capybara system testing and selenium driver 55 gem 'capybara', '>= 2.15' 56 gem 'selenium-webdriver' 57 # Easy installation and use of chromedriver to run system tests with Chrome 58 gem 'chromedriver-helper' 59end 60 61# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 62gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 63gem 'haml-rails'
以上を試したのですがcssは反映されません。本気で困ってます。聞ける人が周りにいないので回答いただけるとありがたいです。よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー