質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Sass

Sassは、プログラミング風のコードでCSSを生成できるスタイルシート言語です。 scss ファイルを、変換(コンパイル)してCSSファイルを作成します。

Q&A

解決済

2回答

3755閲覧

rails scssが反映されません

gsbzn_

総合スコア4

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Sass

Sassは、プログラミング風のコードでCSSを生成できるスタイルシート言語です。 scss ファイルを、変換(コンパイル)してCSSファイルを作成します。

0グッド

0クリップ

投稿2021/04/16 17:08

編集2021/04/17 08:27

railsでwebアプリを作成中です。
cssは反映されるのですが、scssが反映されません。

@import 'welcome.scss'; や
*= require_tree .
*= require_self
の記載があるか等調べて試してみたのですが解決できませんでした。
ご教授いただけないでしょうか。

rails 5.2.4
ruby 2.6.2
dockerを用いて開発しています。

welcome.scss

#welcome-index { .content-wrapper{ display: flex; .content-block{ background-color: blueviolet; width: 80%; height: 200px; } .sidebar{ background-color: cornflowerblue; width: 20%; height: 200px; } } }

application.css.scss

@import 'welcome'; /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's * vendor/assets/stylesheets directory can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * *= require_tree . *= require_self */ #header { display: flex; align-items: center; justify-content: space-between; } #header #nav { list-style: none; display: flex; } #header #nav li { width: 140px; text-align: center; background-color: #333; height: 50px; line-height: 50px; margin-right: 2px; } #header #nav li a { text-decoration: none; color: #fff; font-weight: bold; padding: 20px; } #footer { background-color: #333; color: #fff; text-align: center; padding: 10px 0px; font-size: 13px; margin-top: 20px; } #footer p { margin: 0px; }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

body id と全角のスペースがあった為反映されませんでした。
今後は拡張ツール導入で対策します。

投稿2021/05/09 02:54

gsbzn_

総合スコア4

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

Htmlからは呼び出していますか?

application.html.erbからも呼び出しておかないとと反映されませんよ。

投稿2021/04/19 09:37

yaha4967

総合スコア106

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

gsbzn_

2021/04/19 13:31

ご回答ありがとうございます。 application.html.erbにも@importを記載するということでしょうか。 他に https://qiita.com/Y_ASAMOTO/items/d5f33ecf5bfbb7f028a5 こちらのSassを使用する準備をするという項目の箇所を試してみましたが 改善されませんでした。
yaha4967

2021/04/20 00:16

いいえ。 その記事のやり方とちょっと違うのですが、これをheadに入れてみてください。 <%= stylesheet_link_tag "application", :media => "all" %>
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問