在悬停覆盖层之前和之后添加延迟内容
P粉731861241
P粉731861241 2023-08-02 17:34:53
0
1
603
<p>当我悬停在一个div上时,我希望有一个从左到右滑动的覆盖层,然后在1秒延迟后内容变得可见。这是我的HTML代码:</p> <p><br /></p> <pre class="brush:css;toolbar:false;">/* overlay */ .overlay { position: absolute; bottom: 0; left: 0; right: 0; background-color: rgba(255, 255, 255, 0.9); overflow: hidden; width: 0; height: 100%; transition: .5s ease; } .dv-each:hover .overlay { /* transition-delay: 0.4s; */ transition: .5s ease-in-out; width: 100%; } .overlay-content { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); white-space: nowrap; }</pre> <pre class="brush:html;toolbar:false;"><div class="col-12 col-md-5 col-lg-4 p-0 m-1 dv-each position-relative h-75"> <a href="{{ route('xdsoft.tintuc')}}"> <img src="{{ asset('image/TrangChu/rectangleLogo4.png') }}" class="img-fluid w-100" alt="..."> <div class="overlay"> <div class="text w-100 h-100 overlay-content px-3 py-4"> <div class="fs-4"> {{-- Some text --}} </div> {{-- <div style="display: flex; justify-content: flex-end;"> <a href="{{ route('xdsoft.thietke')}}"> <div class="bg-145982 text-white p-2">Xem thêm</div> </a> </div> --}} </div> </div> </a> </div></pre> <p><br /></p> <p>当您悬停在图像上时,可以看到白色背景会滑动,内部内容将会显示出来。我想要延迟1秒才显示。您能帮助我吗?谢谢。</p>
P粉731861241
P粉731861241

全部回复(1)
P粉797855790

希望这是您所寻找的。

请更改照片的URL。我使用了从互联网上找到的一张照片。



  .overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(255, 255, 255, 0.9);
  overflow: hidden;
  width: 0;
  height: 100%;
  transition: .5s ease;
  transition-delay: 1s;
  /* Set Delay Duration */
}

.dv-each:hover .overlay {
  transition: .5s ease-in-out;
  width: 100%;
  transition-delay: 0s;
}

.overlay-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1s ease;
  .dv-each:hover .overlay-content {
    opacity: 1;
  }
<div class="col-12 col-md-5 col-lg-4 p-0 m-1 dv-each position-relative h-75">
  <a href="{{ route('xdsoft.tintuc')}}">
    <img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_1280.jpg" class="img-fluid w-100" alt="...">
    <div class="overlay">
      <div class="text w-100 h-100 overlay-content px-3 py-4">
        <div class="fs-4">
          Text Displayed after Delay
        </div>
        <div style="display: flex; justify-content: flex-end;">
          <a href="{{ route('xdsoft.thietke')}}">Text Displayed after Delay
                                <div class="bg-145982 text-white p-2"></div>
                              </a>
        </div>
      </div>
    </div>
  </a>
</div>


热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板