使用变换比例的Z-index问题

时间:2015-06-12 02:11:59

标签: css css3 css-transitions

我下面有一个codepen。基本上,我试图在突出显示的圆圈(红色)上显示一个弹出窗口,但是有些突出显示的圆圈显示在某些弹出窗口之上,即使弹出窗口总是始终被赋予更高的z-index。 / p>

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

这是用于弹出窗口的动画,我认为这可能是罪魁祸首。

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

2 个答案:

答案 0 :(得分:0)

取出.white-popup上的z-index设置,并在.white-popup上设置更高的z-index:hover .popup和.white:hover。 见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;
  }
}

答案 1 :(得分:0)

我添加了以下CSS:

td:hover {
    z-index: 1;
}

.white-popup选择器内,我删除了:

z-index: 2;

线。

似乎适合我。