简体   繁体   中英

Image_tag in rails

I've written this:

<div id="Table_01">
    <div id="SAVEonSHIRTS-website-homepage-01">
        <image_tag("SAVEonSHIRTS_website_homepage_01.png")>
    </div>
    <div id="SAVEonSHIRTS-website-homepage-02">
        <image_tag("SAVEonSHIRTS_website_homepage_02.png")>
    </div>
    <div id="SAVEonSHIRTS-website-homepage-03">
        <image_tag("SAVEonSHIRTS_website_homepage_03.png")>
    </div>

Images are in the images folder under the assets folder. However, images are still not showing up in localhost. Any thoughts?

Thanks in advance!

Elton

I'm assuming you are using erb , if so you need to be using the erb scriptlet tags <%= ... %>

Example:

<%= image_tag("SAVEonSHIRTS_website_homepage_01.png") %>

Reference documentation: Layouts and Rendering in Rails .

you can try with the following

<%= image_tag("SAVEonSHIRTS_website_homepage_01.png", :alt => "Sample App", :class => "round" , :width => "300") %>

alt => If image is not present then this message will be displayed
class => If you want to assign any class
width/hight => if you want to specify specify width and height .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM