LoginSignup
1
1

More than 3 years have passed since last update.

Railsで画像を使用する

Posted at

Railsで画像を使用する。

利用したい画像ファイルをapp/assets/imagesに入れておく。
画像を使用したいhtml.hamlファイルにて、

html.haml
= image_tag src= "/assets/sample.png", size: "50x50"

Railsで背景画像をcssで指定する。

背景として利用した画像ファイルをapp/assets/imagesに入れておく。
そしてcssファイルにて

css
background: image-url("sample.png");
background-size: cover;
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