Home>
Development environment

rails 6
ruby 2.6.5

Thing I want to do

I want to display an image in the background.

What I tried myself

I referred to Qiita's article, but it is not displayed.
https://qiita.com/shimadama/items/04db0746d2fc9bb7c41f
https://qiita.com/knxrvb/items/c78c08a0a3c9d4095f3f

background-image: url (../../images/set1.png)! important;
By declaring! Important in selector style, I try the most important rules but I don't see them.

Other properties have been applied.
You can also check the image path in the editor.
Even if I change it to a p tag, it cannot be displayed.

Image folder
app/assets/images/set1.png

app/assets/stylesheets/device/signup.scss

.signup-wrapper {
  height: 100vh;
  width: 100%;
  background-image: url (../../images/set1.png);
  background-size: cover;
}


html.erb


  • Answer # 1

    .signup-wrapper {
      background-image: image-url ('set1.png');
    }


    Reference: Rails Guide

  • Answer # 2

    background-image: image-url ('set1.png');

    The description you taught me worked.

Related articles