Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

z-index not working with my animation

The following code (html & css) drives me crazy... jsfiddle link

How can I use z-index (or anything else) to have the 3 circles always visibles. With the blue one it's ok, but the yelow and the red one hide the circle on their left.

Thanks in advance for you help !

<div id="rSociaux" class="col-md-6 noSpace">
<a href="http://www.facebook.com/lesdieuxduvin" target="_blank" id="bg-fb" class="tile-share">
    <div  class="social-color-bg fb"></div>
    <svg class="ontop" height="100" width="100">
        <circle cx="50" cy="50" r="20"  fill="blue" />
    </svg>
</a>
<a href="http://www.twitter.com/lesdieuxduvin" target="_blank" class="tile-share">
    <div class="social-color-bg twitter"></div> 
    <svg class="ontop" height="100" width="100">
        <circle cx="50" cy="50" r="20"  fill="yellow" />
    </svg>
</a>
<a href="http://www.twitter.com/lesdieuxduvin" target="_blank"  id="bg-li" class="tile-share">
    <div class="social-color-bg linkedin"></div> 
    <svg class="ontop" height="100" width="100">
        <circle id="svgLi" cx="50" cy="50" r="20"  fill="red" />
    </svg>
</a>

CSS:

#rSociaux {
background-color: #a55fa2;
}

.ontop {
position: relative;
z-index: 10;
}

.tile-share {
display: inline-block;
position: relative;
left: 33%;
-webkit-transform: translateX(-50%) translateY(-0%);
-moz-transform: translateX(-50%) translateY(-0%);
-ms-transform: translateX(-50%) translateY(-0%);
-o-transform: translateX(-50%) translateY(-0%);
transform: translateX(-50%) translateY(-0%);
}

#rSociaux {
overflow: hidden;
}

#rSociaux svg {
position: relative;
z-index: 1000; }

#rSociaux .social-color-bg {
pointer-events: none;
position: absolute;
border-radius: 100%;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
-o-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-transition: 1s;
-moz-transition: 1s;
-o-transition: 1s;
transition: 1s;
}

#rSociaux .social-color-bg.fb {
background: blue;
}

#rSociaux .social-color-bg.twitter {
background: yellow;
}

#rSociaux .social-color-bg.linkedin {
background: red;
}


#rSociaux .tile-share:hover .social-color-bg {
width: 100% !important;
height: 100% !important;
-webkit-transform: scale(20);
-moz-transform: scale(20);
-ms-transform: scale(20);
-o-transform: scale(20);
transform: scale(20);
}
like image 523
Arnaud Papa Avatar asked Feb 09 '23 21:02

Arnaud Papa


2 Answers

Adding the following:

#rSociaux .tile-share{
    z-index:10;
}

#rSociaux .tile-share:hover{
    z-index:9;
}

and removing the other z-index references solves the problem

here is the working fiddle

like image 146
HelloWorld Avatar answered Feb 12 '23 13:02

HelloWorld


Your z-index doesn't work because you're applying it to completely different elements. Use the same element for hover and non-hover based z-index changes. z-index is not an absolute value where always the element with higher z-index will be on top.

.tile-share{
   z-index: 5;
}

.tile-share:hover{
    z-index: 3;
}

http://jsfiddle.net/dqup4ptf/4/

like image 21
connexo Avatar answered Feb 12 '23 12:02

connexo