2015-03-03 178 views
-4

我有this site。在頁腳中,我有一個包含社交圖標的列表。懸停圖像效果CSS

這是HTML代碼:爲.social-list

<div class="social-list"> 
    <ul> 
     <li id="first"><img src="http://eventos.dac-proiect.ro/wp-content/themes/eventos/images/gri1.png" alt="Smiley face" height="30" width="30"></li> 
     <li><img src="http://eventos.dac-proiect.ro/wp-content/themes/eventos/images/gri2.png" alt="Smiley face" height="30" width="30"></li> 
     <li><img src="http://eventos.dac-proiect.ro/wp-content/themes/eventos/images/gri3.png" alt="Smiley face" height="30" width="30"></li> 
     <li><img src="http://eventos.dac-proiect.ro/wp-content/themes/eventos/images/gri4.png" alt="Smiley face" height="30" width="30"></li> 
     <li><img src="http://eventos.dac-proiect.ro/wp-content/themes/eventos/images/gri5.png" alt="Smiley face" height="30" width="30"></li> 
    </ul> 
</div> 

這是CSS代碼:

.social-list { 
    float: left; 
    display: inline-block; 
    margin-left: -92px; 
} 

我要創建在圖像的效懸停。

我想這樣做,但它不工作:

#first:hover { 
    background:url("http://eventos.dac-proiect.ro/wp-content/themes/eventos/images/roz1.png"); 
} 

什麼是錯的代碼?

+1

我沒有看到您的網站上的第一個鋰的任何ID。緩存問題? – Brewal 2015-03-03 14:13:24

+0

你想創建什麼樣的效果? – bbvanee 2015-03-03 14:14:41

+0

請說明你想要什麼樣的效果? – Kumar 2015-03-03 14:14:56

回答

1

問題是,您正在將背景更改爲li,但圖像仍位於頂部,因此它覆蓋了它並且看不到它。

這個想法是刪除li中的img,並專門用於li背景。就像這樣:

#first { 
    background-image:url('http://eventos.dac-proiect.ro/wp-content/themes/eventos/images/gri1.png'); 
    width:30px; 
    height:30px; 
    display:inline-block; 
} 

#first:hover { 
    background-image:url('http://eventos.dac-proiect.ro/wp-content/themes/eventos/images/roz1.png'); 
} 
+0

我添加了您的代碼,但我遇到了同樣的問題 – 2015-03-03 14:21:49

+0

您是否刪除了圖像?你還需要指定'li'的寬度/高度來使它工作。 – 2015-03-03 14:22:33

+0

徘徊的圖像沒有放置在我需要的位置...對您執行此代碼? – 2015-03-03 14:27:48