在嵌套div中悬停显示不起作用

时间:2016-04-20 13:50:16

标签: html css font-awesome

我正在制作一个弹出屏幕右侧的菜单。 https://jsfiddle.net/grhajrbp/

HTML:

  <div id="east-exit">
    <div id="mail-option">
      <a ng-click="controller.openEmails()"><i class="communicate-icon mail fa fa-envelope"></i></a>
      <a><i class="new-mail fa fa-plus-circle"></i></a>
    </div>
    <a><i class="communicate-icon fa fa-comments"></i></a>
    <i class="east-exit-icon fa fa-arrow-right"></i>
    <a><i class="communicate-icon fa fa-phone"></i></a>
    <a><i class="communicate-icon fa fa-camera"></i></a>
  </div>

CSS:

html {
  width: 100%;
  height: 100%;
  position: absolute;
  overflow: hidden;
  font-family: 'Roboto', sans-serif;
}

#east-exit {
  display: flex;
  opacity: 1;
  z-index: -1;
  align-items: stretch;
  justify-content: space-around;
  flex-direction: column;
  position: absolute;
  right: 0;
  height: 100%;
  width: 85px;
  font-size: 55px;
}

#east-exit:hover .east-exit-icon {
  -webkit-transition: all .2s ease;
  -moz-transition: all .2s ease;
  -o-transition: all .2s ease;
  -ms-transition: all .2s ease;
  transition: all .2s ease;
  opacity: 0;
}

#east-exit:hover .communicate-icon {
  -webkit-transition: all .3s ease;
  -moz-transition: all .3s ease;
  -o-transition: all .3s ease;
  -ms-transition: all .3s ease;
  transition: all .3s ease;
  opacity: 1;
}

#east-exit:hover,
#mail-option:hover,
.mail:hover .new-mail {
  -webkit-transition: all .3s ease;
  -moz-transition: all .3s ease;
  -o-transition: all .3s ease;
  -ms-transition: all .3s ease;
  transition: all .3s ease;
  opacity: 1;
}

.east-exit-icon {
  -webkit-transition: all .2s ease;
  -moz-transition: all .2s ease;
  -o-transition: all .2s ease;
  -ms-transition: all .2s ease;
  transition: all .2s ease;
  font-size: 45px;
  opacity: 0.1;
}

.communicate-icon {
  z-index: 1;
  -webkit-transition: all .3s ease;
  -moz-transition: all .3s ease;
  -o-transition: all .3s ease;
  -ms-transition: all .3s ease;
  transition: all .3s ease;
  color: darkgrey;
  opacity: 0;
}

.new-mail {
  z-index: 1;
  -webkit-transition: all .3s ease;
  -moz-transition: all .3s ease;
  -o-transition: all .3s ease;
  -ms-transition: all .3s ease;
  transition: all .3s ease;
  color: darkgrey;
  opacity: 0;
}

.communicate-icon:hover,
.communicate-icon:focus,
.communicate-icon:active {
  -webkit-transform: scale(1.2);
  transform: scale(1.2);
  -webkit-transition-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);
  transition-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);
  color: grey;
  cursor: pointer;
}

菜单显示四个按钮。如果我将鼠标悬停在邮件按钮上,则会在邮件按钮旁边显示一个小加号按钮。我目前只是试图让悬停时显示加号按钮(它不在正确的位置。我无法在邮件按钮悬停时显示加号按钮。有没有人知道如何这样做?

此外,我还尝试使用flexbox将按钮放在正确的位置。 (下图显示了它应该去的地方)。我也无法让这个工作。有没有人有任何我可以尝试的建议?第一张图片: Closed east-menu 第二张图片: Opened east-menu 第三张图片: This is where the plus button should go

1 个答案:

答案 0 :(得分:0)

您可以使用以下css规则

.communicate-icon.fa.fa-envelope:hover {
    background: url(<image name>);
    background-repeat: no-repeat;
    background-position: -40px 0; // Change as needed
}

您还需要使div更宽或不显示背景图像。