I have an accordion that i want to transition only when i open it, but i don’t want it to transition when it leaves. To visualize it, open and close the chat box where you are writing on freecodecamp.
transition: max-height 0.6s ease;
I thought that ease will remove the exit transition, but it doesnt seem like so.
My first thought is that you have a class with the transition in it.
opening { transition: max-height; etc }
Once the accordion is open, you toggle off that class. Then when you close it, it won’t transition.
It might help if we can see the code. It can depend on where the transition is defined.
For example, this code will only have a transition on the hover (i.e. the .box growing):
<div class="box"></div>
.box {
height: 80px;
width: 250px;
background: red;
}
.box:hover {
height: 200px;
transition: height .3s ease;
}
This will have it on both (i.e. the .box growing and shrinking):
.box {
height: 80px;
width: 250px;
background: red;
transition: height .3s ease;
}
.box:hover {
height: 200px;
}