Issue
I'm using the following code to animate v-if element by reducing the height to 0px from. The animation works fine. But the problem is I've to specify the initial height of the element is CSS. For one element this is ok, But I want to apply this animation to multiple elements. How can I fix this? So that whatever be the height, animation works fine!
<transition name="fadeHeight" mode="out-in">
<div v-if="something">
<p>something over here where the height is not constant</p>
</div>
</transition>
.fadeHeight-enter-active,
.fadeHeight-leave-active {
transition: all 0.2s;
height: 230px;
}
.fadeHeight-enter,
.fadeHeight-leave-to
{
opacity: 0;
height: 0px;
}
Solution
It doesn't look like you've posted all the code, but hopefully I understand the goal.
Try moving the transition to the max-height property:
.fadeHeight-enter-active,
.fadeHeight-leave-active {
transition: all 0.2s;
max-height: 230px;
}
.fadeHeight-enter,
.fadeHeight-leave-to
{
opacity: 0;
max-height: 0px;
}
as long as you set a max height to be larger than the tallest element, it should accomplish what you need. Note that you may also want to use overflow:hidden as well. If you have dramatic variation of the actual height of the elements, this solution may not be the best, as it will make the animation duration/delay appear very different.
https://jsfiddle.net/7ap15qq0/4/
Answered By - ryantdecker
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.