I am trying to show child div with the transition from the bottom of parent div on hovering on parent div.
Here is what I tried:
JavaScript
x
15
15
1
.parent {
2
min-height: 370px;
3
}
4
5
.child {
6
position: absolute;
7
bottom: 0;
8
width: 100%;
9
height: 0;
10
transition: height 2s;
11
}
12
13
.parent:hover child {
14
height: 30px;
15
}
JavaScript
1
3
1
<div className="parent">
2
<div className="child">View More</div>
3
</div>
But It is not working as even with height 0, “View More” is still visible and the transition is not working as well.
Advertisement
Answer
Try to add a class selector for child after hover .
And you can add transition for opacity for better effect)
JavaScript
1
4
1
.parent:hover .child {
2
height:30px;
3
}
4