Reputation: 275
I'm having a hard time getting a color overlay (and image) to appear when hovering over an image.
Essentially, the user should see this overlay (which is separated in 2 below):
I have the following HTML snippet:
<ul id="Grid">
<li class="mix category_1 mix_all" style="display: inline-block; opacity: 1;">
<img src="http://i.imgur.com/J4PaouI.jpg" alt="#">
</li>
</ul>
Here is the particular CSS (and a z-index just to be sure):
.mix_all:hover {
background: url(http://i.imgur.com/0lu7dWs.png) no-repeat center !important;
background-color: #de6573 !important;
z-index: 99999999;
}
#Grid .mix {
width: 200px;
height: 200px;
margin-bottom: 20px;
}
.mix.mix_all img {
max-height: 200px;
max-width: 200px;
}
Here is a link to the fiddle:
Upvotes: 0
Views: 867
Reputation: 3079
Here is a correct version: http://jsfiddle.net/maximgladkov/b2twr/1/
You should add an additional element with position: absolute
and show it.
<ul id="Grid">
<li class="mix category_1 mix_all">
<img src="http://i.imgur.com/J4PaouI.jpg" alt="#" />
<div class="overlay"></div>
</li>
</ul>
.mix_all {
position: relative;
}
.mix_all .overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.mix_all:hover .overlay {
background: url(http://i.imgur.com/0lu7dWs.png) no-repeat center !important;
background-color: #de6573 !important;
z-index: 99999999;
}
Upvotes: 2