2015-03-03 248 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