2016-03-02 22 views
0

我正在嘗試設置我的link_to幫助程序的樣式。我想添加一個圖標而不是鏈接並禁用所有效果。我遵循這個方法Remove underline from link within hyperlinked div,但它不適合我,只要我將鼠標懸停在圖標上消失,這不是我想要的。這是迄今爲止我所擁有的。將glyphicon添加到rails link_to helper,並禁用懸停時的效果

<div id = "owner-icons"> 
<%= link_to product, method: :delete, data: { confirm: 'Are you sure?' } do %>  
<span class="glyphicon glyphicon-trash"></span> 
</div> 
<% end %> 

bootstrap.css

div.owner-icons a {text-decoration:none;} 

可以改變圖標的​​顏色呢?

+1

更改圖標的顏色,通過添加CSS顏色屬性吧。 或div.owner-icons span {color:red!important;} –

+0

謝謝我能夠改變顏色。 – A1X

+0

好的,很高興聽到。你也可以通過改變父母的顏色來改變bootstrap的顏色。請在我的答案投票)) –

回答

2

您的simpy添加​​給你鏈接是這樣的:

查看(幫我換your_url

<div id="owner-icons"> 
    <%= link_to '', your_url, method: :delete, data: { confirm: 'Are you sure?' }, class: 'glyphicon glyphicon-trash' %> 
</div> 

風格

#owner-icons a { 
    color: red; # your custom color 
    text-decoration: none; 
} 

順便說一下,在當前的代碼有一些問題:

  • owner-iconsidclass,所以你的CSS將無法正常工作
  • </div>關閉標籤是不是在正確的地方,我認爲

更新

添加hover樣式鏈接:

  • 如果您正在使用sc SS

    #owner-icons a { 
        color: red; # your custom color 
        text-decoration: none; 
        &:hover { 
        background: transparent; # Your custom background 
        } 
    } 
    
  • 或純CSS

    #owner-icons a { 
        color: red; # your custom color 
        text-decoration: none; 
    } 
    #owner-icons a:hover { 
        background: transparent; # Your custom background 
    } 
    
+0

它改變了顏色,但仍然只要我把它懸停在上面,它的背景現在變成黑色,這意味着文字修飾:無;沒有工作,我猜? – A1X

+0

你可以添加懸停風格到你的CSS,結帳我的更新! –

+0

謝謝你工作yaaay! – A1X