When I hover a div, I wanted to have an overlay that slide from left to right, and then the content would visible after 1s delay. This is my HTML code:
/* 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;
}
<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>
As you can see, when I hover the image, the white background will slide and the content inside just visible. I want to make it delay for 1s. Can you help me? Thanks.
2
Answers
I hope this is what you are looking for.
Please change the URL of the Photo. I have used one from the Internet.
Modified Code
With my understanding you will need
js
for it. I dunno if this is what you wnatThink of your background image, your overlay and your overlay content as three independent layers which stack on top of each other. Then code it that way.
In your
:hover
rules, set thetransition-delay
to the delay you want when the hover begins, then in your base rules set thetransition-delay
to the delay you want when the hover ends.