IMG hover not working

血红的双手。 提交于 2019-12-31 06:58:12

问题


I have problem with my hover on img in my #picutre div. HTML:

<div id="picture">
      <img class="content_pic" src="image/exemple.jpg" alt="exemple"/>
      <img class="content_pic" src="image/exemple.jpg" alt="exemple"/>
</div>

And my CSS looks like this:

#picture {
text-align:center;
}

#picture img {
width:40%;
height:40%;
border:1px solid #000000;
display:inline-block;
margin-left:0;
margin-right:0;
opacity:0.4;
}

.content_pic:hover{
opacity:1.0;
}

So i'm wondering why it doesn't work. I'm using Google Chrome, checked IE10 too but not working there too.


回答1:


#picture img is more specific than .content_pic:hover so opacity:0.4; will always overwrite opacity:1.0;.

Use #picture img:hover instead.




回答2:


You have given the picture img opacity 0.4 and hover effect for .content_pic:hover so this vl not work.

see the fiddle here http://jsfiddle.net/4z55sjn0/2/



来源:https://stackoverflow.com/questions/28296941/img-hover-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!