简体   繁体   English

导轨中的image_tag

[英]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 <%= ... %> 我假设您正在使用erb ,如果需要,则需要使用erb scriptlet标签<%= ... %>

Example: 例:

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

Reference documentation: Layouts and Rendering in Rails . 参考文档: 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 .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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