LoginSignup
1
1

More than 3 years have passed since last update.

Thymeleaf使用時にcssが適用されない問題

Last updated at Posted at 2018-08-08

SpringBootでの開発で、cssファイルが適用されなかったときの備忘録。

原因

原因は大体この二つのどちらかです。

1.普通にcssの構文が間違っている

  • ;が足りない
  • {}が閉じてない
  • .class{...}のドット忘れ
  • #id{...}のシャープ忘れ

2.パスが間違えている

SpringBootでは、cssファイルは、resouses/static/css/の中に入れなくてはいけません。

 だめ

src/main/
┣ java
┗ resouses
    ┗ templates
        ┣ index.html
        ┗ css
           ┗ style.css

 おっけー

src/main/
┣ java
┗ resouses
    ┣ static
    ┃   ┗ css
    ┃            ┗ style.css
    ┗ templates
        ┗ index.html
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1