0
0

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 3 years have passed since last update.

haml imageタグ

Posted at

hamlのimageタグの使い方を学んでいたのですが、「class」属性が付けられなかったので、
備忘録のために記述します。(class属性が付与できずcssをあてらなくて困った( T_T) )

やりたいこと

hamlのimageタグ「class:」属性を付けたい!

記述方法

html

<img src="verification/doraemon.png" alt="自分のイラスト" class="myimage" >

haml

= image_tag "verification/doraemon.png", alt: "自分のイラスト", class: "myimage"

結果

無事にクラス属性を付与できた。
cssで画像サイズを変更したかったのですが、class属性が付与できず直接タグの中にサイズ書いてのがスッキリできました。

# before
= image_tag "verification/doraemon.png", size: "100x80", alt: "自分のイラスト"
# after
= image_tag "verification/doraemon.png", alt: "自分のイラスト", class: "myimage"
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?