簡體   English   中英

為image_tag添加標題Ruby on Rails

[英]Adding caption to image_tag Ruby on Rails

我想知道如何在rails中為我的image_tag添加標題。 這是它喜歡的東西:

<%= image_tag "img1.jpg", :class => "rounded float-left", :height => '400px' %>

反正在這張圖片下方添加了標題。 謝謝 :)

我知道沒有Rails助手,但是這樣的東西應該給你一個圖片下方的標題:

<figure>
    <%= image_tag "img1.jpg", :class => "rounded float-left", :height => '400px' %>
    <figcaption>Caption goes here</figcaption>
</figure>

如果考慮標題,可以添加標題:title => "title" 如果沒有,最好創建一個幫助器,輸出圖像,文本居中並在下方對齊。

例:

<div class="figure">
  <img src=""/>
  <p class="caption">
    <span class="caption-text">Some caption of any length</span>
   </p>
</div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM