I'm trying to create a div that appears on hover by rotating in X
position from top to bottom, I also want to add some realistic to it's rotation(The width of the DIV from the bottom should always be 100%, but should increase gradually from 20% to 100% white it's rotating).
.img-event-parent{
position: relative;
}
.img-event-details{
position: absolute;
background-color: rgba(0,0,0,0.8);
left: 0px;
right: 0px;
top: 0px;
height: 100%;
transform: rotateX(90deg);
transform-style: preserve-3d;
-webkit-transform: rotateX(90deg);
transform-origin: bottom;
transition: all 3s;
}
.img-event-parent:hover .img-event-details{
transform: rotateX(0deg);
}
<div class="img-event">
<div class="img-event-parent img-parent">
<a href="#">
<img src="https://images.pexels.com/photos/20787/pexels-photo.jpg?auto=compress&cs=tinysrgb&h=350" alt="">
</a>
<div class="img-event-details">
<a href="#" class="slick-desc"><?=$key->post_title?></a>
</div>
</div>
</div>
The snippet above rotates the img-event-details
div, but I don't know how can I resize the div width from the top only(As shown in the image above) while rotating.
Add some perspective:
.img-event-parent {
position: relative;
display: inline-block;
perspective: 200px; /*Added this*/
perspective-origin: bottom; /*Added this*/
}
.img-event-parent img {
display: block;
}
.img-event-details {
position: absolute;
background-color: rgba(0, 0, 0, 0.8);
left: 0px;
right: 0px;
top: 0px;
height: 100%;
transform: rotateX(90deg);
transform-style: preserve-3d;
transform-origin: bottom;
transition: all 3s;
}
.img-event-parent:hover .img-event-details {
transform: rotateX(0deg);
}
<div class="img-event">
<div class="img-event-parent img-parent">
<a href="#">
<img src="https://images.pexels.com/photos/20787/pexels-photo.jpg?auto=compress&cs=tinysrgb&h=300" alt="">
</a>
<div class="img-event-details">
<a href="#" class="slick-desc">Some text</a>
</div>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With