Z-index issue using transform scale

1.6k views Asked by At

I have a codepen below. Basically, I'm trying to show a popup on hover of the highlighted circles (red), however some highlighted circles are showing up above some of the popups, even when the popups are always given a higher z-index all the time.

http://codepen.io/Wolfmans55/pen/jPwKqZ

This is the animation used for the popup, which I believe maybe the culprit.

@-webkit-keyframes popup {
 0% {
    transform: scale(2.5);
  }
  100% {
    transform: scale(0);
  }
}
2

There are 2 answers

0
imnancysun On

Take out the z-index setting on .white-popup and set a higher z-index on .white-popup:hover .popup and .white:hover. see jsfiddle

    @import url(http://fonts.googleapis.com/css?family=Roboto);
body,
html {
  height: 100%;
}
body {
  background: #343837;
  transition: opacity .25s;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
  overflow: hidden;
}
.show-body {
  opacity: 1;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
}
.page {
  background: #343837;
  font-family: 'Roboto', sans-serif;
  font-size: 100%;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: all 1s;
}
.page-2 {
  left: auto;
  right: -100%;
  background: blue;
}
.prev-page,
.next-page {
  position: absolute;
  top: 50%;
  width: 50px;
  height: 50px;
  background: red;
}
.next-page {
  right: 20px;
}
.prev-page {
  left: 20px;
}
.page-wrapper {
  position: absolute;
  top: 50%;
  margin-top: -303px;
  width: 100%;
}
.header_section {
  text-shadow: 1px 1px 1px #000;
  font-size: 2em;
}
h1 {
  margin: 0;
}
.blue_title {
  color: #54c8e7;
  font-weight: normal;
}
.primary_title {
  font-size: 4em;
  margin-top: -34px;
  margin-bottom: 20px;
}
.sub_title {
  position: relative;
  font-size: 1em;
  background: #343837;
  padding: 0 4px;
  display: inline-block;
}
.sub_title_divider {
  border-top: 1px solid #54c8e7;;
  position: absolute;
  top: 20px;
  left: 0;
  width: 100%;
}
.city-name {
  font-size: 2em;
}
.emphasis {
  font-weight: bold;
}
.inlineblock {
  display: inline-block;
}
.centertxt {
  text-align: center;
}
.pos_rel {
  position: relative;
}
.overflow_hidden {
  overflow: hidden;
}
.vert_mid {
  vertical-align: middle;
}
table { 
  cursor: pointer;
  margin: 0 auto;
  border-spacing: 1px;
} 
td {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.white,
.white-popup {
  background: #000;
  position: relative;
  -webkit-animation: in .25s;
}
.white-popup {
  background: red;
}
/*.plan-to {
  background: #018c9e;
  z-index: 2;
}*/
.white-popup .popup {
  cursor: auto;
  -webkit-animation: popup .25s forwards;
  z-index: 10;
}
.popup {
  position: absolute;
  width: 100px;
  height: 100px;
  font-size: 5px;
  overflow: hidden;
  background: #54c8e7;
  z-index:10;
  top: -45px;
  left: -45px;
  padding: 8px;
  border: 1px solid #343837;
  border-radius: 3px;
  box-sizing: border-box;
}
.white-popup:hover .popup { 
  -webkit-animation: out .25s forwards;
    z-index: 50;
}
.white:hover {
  -webkit-animation: out .25s forwards;
    z-index: 50;
}

@-webkit-keyframes in {
    from {background:#fff; transform: scale(1);}
    to {background: #54c8e7; transform: scale(2.5);}
}

@-webkit-keyframes out {
    0% {background:#fff; transform: scale(1);}
    100% {background: #54c8e7; transform: scale(2.5);}
}

@-webkit-keyframes popup {
  0% {
    transform: scale(2.5);
  }
  100% {
    transform: scale(0);
  }
}


.key {
  height: 15px;
  width: 15px;
   border-radius: 50%; 
  border: 1px solid #ccc;
  margin-right: 2px;
}
.key_1 {
  background: #54c8e7;
}
.key_2 {
  background: #018c9e;
}
.key_3 {
  background: #fff;
}
.legend {
  text-transform:uppercase;
  font-size: 12px;
  color: #fff;
  margin-bottom: 30px;
}
.legend_item {
  margin-left: 15px;
}

@media screen and (min-width: 768px) {
  .page-wrapper {
    margin-top: -388px;
  }
  td {
    width: 15px;
    height: 15px;
  }
}
0
Norman Breau On

I added the following CSS:

td:hover {
    z-index: 1;
}

And inside .white-popup selector, I removed:

z-index: 2;

line.

Seems to work for me.