0

我的.img-wrapper父 div 里面有不同的 div,因为 div.button-holder从底部向下 50px 并且它也被绝对定位,它导致在父 div 之后覆盖元素,在这种情况下,p元素使父 div 的悬停效果即使悬停在p元素上也处于活动状态。希望你明白我的意思。我怎样才能解决这个问题 ?

的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);
 }
4

1 回答 1

-1

我没有完全得到你想要获得的结果,但你为什么不直接使用 simplemargin-top: 50px而不是translate? 这将防止元素溢出容器。

于 2019-05-31T14:09:00.297 回答