0
2

More than 3 years have passed since last update.

【Sass】【Rails】 画像&背景画像を入れる

Last updated at Posted at 2020-05-07

目的

railsアプリ を作っている時に背景や画像を入れるやり方がわからなかったので

前提

載せたい画像をapp/assets/imagesに配置する
app/assets/images/materialに画像の素材を格納

画像

= image_tag "material/app-store.svg", class:"image"

背景画像

background-image: image-url("material/pict/bg-mainVisual-pict_pc.jpg") ;

ポイントは載せたい画像をapp/assets/imagesに配置することです。
images以降の相対パスを記述すればいけます。

スクリーンショット 2020-05-08 0.05.03.png

こんな感じで背景が入れられました

捕捉

下記の記述だと本番環境で画像が表示されませんでした。理由は分かっていないですが、上述のコードでお願いします。

background-image: url(material/pict/bg-mainVisual-pict_pc.jpg) ;
0
2
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
0
2