37
38

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rails5でlink_toとimage_tagを一緒に使う

Posted at

link_toのリンクする文字列を指定するところにimage_tagを入れると使える。

以下にpng画像を配置して、
/public/assets/images/header.png

このようなコードになる。

show.html.haml

= link_to image_tag("/assets/images/header.png", width: '375', alt: "サンプル画像"), topics_path

スマホとPC、それぞれのヘッダー画像を用意して出し分けとかしないとダメなのかな。

ディスプレイサイズで見分ける感じ?

37
38
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
37
38

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?