悬停时无意延迟

问题描述 投票:0回答:1

当我在悬停时立即开始转换,但是当我悬停时,它会在开始反向转换之前等待大约300ms。 (https://jsfiddle.net/vawpnrL9/1/

<div id="isa-hover-gallery">

<a href="https://febc.org/indonesia">
<div class="isa-image" style="background-image:url('https://febc2017.wpengine.com/wp-content/plugins/justified-image-grid/timthumb.php?src=https%3A%2F%2Ffebc2017.wpengine.com%2Fwp-content%2Fuploads%2FEmail-1-Pakistan-Listener-Story_banner-image-900x600.jpg&h=560&w=798&q=45&f=.jpg')">
<div class="slide-text">
<p><b>Sharing His Faith in Pakistan</b></p>
<p>Anam* was given an extraordinary opportunity after he came to faith in Christ…He was asked to preach from the Bible in the mosque his father ran…</p>
</div>
</div>
</a>

</div>

#isa-hover-gallery {
  display: flex;
  flex-wrap: wrap;
}
#isa-hover-gallery .isa-image {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 215px;
  min-width: 320px;
  margin: 0 24px 24px 0;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  cursor: pointer;
}
#isa-hover-gallery .isa-image::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(0,0,0,0);
  transition: 300ms ease-in;
}
#isa-hover-gallery .isa-image > span {
  position: relative;
  z-index: 11;
  opacity: 0;
  color: #ffffff;
  font-size: 20px;
  font-family: 'Open Sans', sans-serif;
  transition: 300ms ease-in;
}
#isa-hover-gallery .isa-image .slide-text {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 4px 6px;
  background-color: rgba(0,0,0,0.8);
  color: #ffffff;
  z-index: 11;
}
#isa-hover-gallery .isa-image .slide-text p:first-child {
  padding-bottom: 0;
}
#isa-hover-gallery .isa-image .slide-text p:last-child {
  max-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  transition: 600ms ease-in;
}
#isa-hover-gallery .isa-image:hover::after {
 background-color: rgba(0,0,0,0.6);
}
#isa-hover-gallery .isa-image:hover > span {
  opacity: 1;
}
#isa-hover-gallery .isa-image:hover .slide-text p:last-child {
  max-height: 1000px;
  margin: auto;
  padding: auto;
}

我尝试了不同的转换速度和禁用其他元素的转换,没有任何帮助。

css css3 css-transitions
1个回答
4
投票

这是因为你动画max-height,你给它一个很大的值,所以你可以通过将max-height减少到更低的值来控制它:

#isa-hover-gallery {
  display: flex;
  flex-wrap: wrap;
}

#isa-hover-gallery .isa-image {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 215px;
  min-width: 320px;
  margin: 0 24px 24px 0;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  cursor: pointer;
}

#isa-hover-gallery .isa-image::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(0, 0, 0, 0);
  transition: 300ms ease-in;
}

#isa-hover-gallery .isa-image>span {
  position: relative;
  z-index: 11;
  opacity: 0;
  color: #ffffff;
  font-size: 20px;
  font-family: 'Open Sans', sans-serif;
  transition: 300ms ease-in;
}

#isa-hover-gallery .isa-image .slide-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right:0;
  padding: 4px 6px;
  background-color: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  z-index: 11;
}

#isa-hover-gallery .isa-image .slide-text p:first-child {
  padding-bottom: 0;
}

#isa-hover-gallery .isa-image .slide-text p:last-child {
  max-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  transition: 600ms ease-in;
}

#isa-hover-gallery .isa-image:hover::after {
  background-color: rgba(0, 0, 0, 0.6);
}

#isa-hover-gallery .isa-image:hover>span {
  opacity: 1;
}

#isa-hover-gallery .isa-image:hover .slide-text p:last-child {
  max-height: 100px;
  margin: auto;
  padding: auto;
}
<div id="isa-hover-gallery">

  <a href="https://febc.org/indonesia">
    <div class="isa-image" style="background-image:url('https://febc2017.wpengine.com/wp-content/plugins/justified-image-grid/timthumb.php?src=https%3A%2F%2Ffebc2017.wpengine.com%2Fwp-content%2Fuploads%2FEmail-1-Pakistan-Listener-Story_banner-image-900x600.jpg&h=560&w=798&q=45&f=.jpg')">
      <div class="slide-text">
        <p><b>Sharing His Faith in Pakistan</b></p>
        <p>Anam* was given an extraordinary opportunity after he came to faith in Christ…He was asked to preach from the Bible in the mosque his father ran…</p>
      </div>
    </div>
  </a>

</div>
© www.soinside.com 2019 - 2024. All rights reserved.