I'm trying to make small image gallery.On :hover there should appear a tooltip on the left side of every image. My HTML code looks like this:
.gallery {
right: 247px;
width: 220px;
}
.gallery li {
display: inline;
width: 100px;
height: 100px;
position: relative;
}
.gallery img {
float: right;
margin: 10px;
box-shadow: 0 0 0 8px rgba(0, 0, 0, 0.3);
-webkit-background-clip: padding-box;
/* for Safari */
background-clip: padding-box;
/* for IE9+, Firefox 4+, Opera, Chrome */
}
.tooltip {
width: 300px;
height: 100px;
display: none;
position: absolute;
right: -108px;
top: 222px;
z-index: 70;
background-color: rgba(0, 0, 0, 0.4);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=40)";
}
.gallery li:hover>.tooltip {
display: inline;
z-index: 70;
}
.gallery li:hover {
background: #fff;
}
.gallery li:hover img {
box-shadow: 0 0 0 8px rgba(255, 255, 255, 1);
}
<ul class="gallery">
<li>
<a href="#" class="thumb"><img src="img/pillow.jpg" alt=""></a>
<div class="tooltip"></div>
</li>
<li>
<a href="#" class="thumb"><img src="" alt=""></a>
<div class="tooltip"></div>
</li>
<li>
<a href="#" class="thumb"><img src="" alt=""></a>
<div class="tooltip"></div>
</li>
<li>
<a href="#" class="thumb "><img src="" alt=""></a>
<div class="tooltip"></div>
</li>
<li>
<a href="#" class="thumb"><img src="" alt=""></a>
<div class="tooltip"></div>
</li>
</ul>
The idea is, as said, that .tooltip has position:absolute and it should appear to the left of hovered <li>
, but somehow it appears at the same place every time. What can be the reason for it?