如何使contaning div不影响父div的悬停

时间:2019-05-31 14:03:06

标签: html css vue.js tailwind-css

我有一个.img-wrapper父div,其中有不同的div,并且由于div .button-holder从底部向下50像素,并且它的位置也绝对会导致在父div之后覆盖元素,因此在这种情况下,即使悬停在p元素上,p元素也会激活父div的悬停效果。希望你明白我的意思。 我该如何解决?

html:

  <div class="w-full px-10 md:px-2 py-10 teammember_big text-left">
        <div class="img-wrapper relative hover:cursor-pointer">
          <img class="w-full block" :src="teammember.picture">
          <div class="img-overlay"></div>
          <div class="work-overlay"><div class="work-description"><div class="work-title" v-text="teammember.title"></div><div class="work-phone"><span>M:</span> <a :href="'tel:' + teammember.phone_number"><span v-text="teammember.phone_number"></span></a></div><div class="work-email"><span>E:</span> <a :href="'mailto:' + teammember.email"><span v-text="teammember.email"></span></a></div></div></div>
          <div class="button-holder"><a class="button">BIO & DETAILS</a>
          </div>
          </div>
        <p class="text-black text-center name" v-text="teammember.name"></p>
        <!--<p class="text-black title" v-text="teammember.title"></p>
        <p class="text-black bio" >Bio & Details</p>-->
      </div>

以及一些用SCSS编写的相关CSS:

.teammember_big {
 .img-overlay {
  background-color: transparent;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  transition: background-color 0.25s ease-in-out;
}
.work-overlay {
 font-family: National-Book;
 border: none;
 background-color: transparent;
 padding: 0;
 position: absolute;
 top: 0;
 right: 0;
 bottom: 0;
 left: 0;
 width: 100%;
 height: 100%;
 opacity: 0;
 backface-visibility: hidden;
 transition: transform 0.15s, opacity 0.15s linear;
 text-align: center;
}
.button-holder {
 opacity: 0;
 position: absolute;
 top: auto;
 bottom: 0;
 left: 0;
 right: 0;
 text-align: center;
 transition: transform 0.35s;
 transform: translate3d(0, 50px, 0);
} 
}
.teammember_big .img-wrapper:hover .img-overlay {
  background-color: rgba(37, 37, 39, 0.8);
 }
.teammember_big .img-wrapper:hover .work-overlay {
  opacity: 1;
  transition: transform 0.35s, opacity 0.35s linear;
  transform: translate3d(0, 20%, 0);
 }
 .teammember_big .img-wrapper:hover .button-holder {
  opacity: 1;
  transition: transform 0.45s, opacity 0.45s linear;
  transform: translate3d(0, -30px, 0);
 }

1 个答案:

答案 0 :(得分:-1)

我没有完全得到想要的结果,但是为什么不使用简单的margin-top: 50px而不是translate