2016-03-29 37 views
0

我在軌上使用模板來創建商業網站。它在着陸頁上有圖像,我想根據圖像指向其他頁面。它看起來像下面的圖片:在軌道上的圖像類上創建鏈接

images to be used as links

代碼的圖像是:

<div class="top-box"> 
       <div class="col_1_of_3 span_1_of_3"> 
       <a href="single.html"> 
       <div class="inner_content clearfix"> 
        <div class="product_image"> 
         <img src="images/pic3.jpg" alt=""/> 
        </div> 
        <div class="price"> 
         <div class="cart-left"> 
          <p class="title">Lorem Ipsum simply</p> 
          <div class="price1"> 
           <span class="actual">$12.00</span> 
          </div> 
         </div> 
         <div class="cart-right"> </div> 
         <div class="clear"></div> 
        </div>    
        </div> 
        </a> 
       </div> 

我在軌道是一個新手,並尋求幫助嗎?

+0

在圖像周圍添加一個鏈接,例如:'' –

+0

就像它已經有了。你可以分享你的代碼現場演示嗎? – Pedram

+0

非常感謝。那完全有效。真的很感激它。我怎樣才能讓整個容器成爲一個鏈接。不是單獨的圖像? –

回答

0

您可以使用link_to方法中的圖像來獲取塊。

<%= link_to image_path(@image) do %> 
    <%= image_tag 'pic3.jpg' %> 
<% end %> 

此外,請確保您使用Rails方法,而不是使用純HTML代碼在應用程序中生成圖像。