On the webpage I'm working on, I have a div that contains an image and another div. The inner div is initially set to
opacity: 0;
so that it is not visible. The inner div should appear above my image when it hangs. I have achieved this, but now I want to improve it further by getting the βoverlayβ div (which appears with an opacity of 0.5) gradually glides over the image. I could do it theoretically using JavaScript, but in this case it should be a pure CSS solution. So far, my solution just makes the overlay div appear gradually (it disappears), but does not slide down, since I have never done this only in CSS.
See the image below to understand further:

HTML:
<div class="img"> <img class="squareImg" src="img1.jpg"/><div class="overlay"> tweet This <br> Buy This</div></div> <div class="img"> <img class="squareImg" src="img3.jpg"/></div> <div class="img"> </img></div>
CSS
.overlay{ position: absolute; width: 200px; overflow-y: hidden; transition-property: all; transition-duration: .5s; transition-timing-function: cubic-bezier(0, 1, 0.5, 1); height: 200px; background-color: red; border: 1px solid white; top: 10px; left: 10px; opacity: 0; } .overlay:hover{ cursor:pointer; opacity: 0.5; z-index: 1; } .img{ position: relative; margin-bottom: 10px; border: 2px solid yellow; background-color: black; width: 200px; height: 200px; left: 50%; margin-left: -110px; padding: 10px; }
source share