It is impossible to run an animation from auto
to Npx
, due to the way animations are constructed.
For example, take this CSS:
.block {
width: 100px;
transition: width 2s;
}
.block:hover {
width: 200px;
}
This would esentialy be the same as the following code:
@keyframes animate-width {
from { width: 100px; }
to { width: 200px; }
}
.block {
width: 100px;
}
.block:hover {
animate: animate-width 2s;
}
As you can see from the animation keyframes, a startpoint and an endpoint are defined in order to be able to create a proper animation.
In order to run an animation a start and endpoint have to be available for the browser's CSS rendering engine to function properly. auto
can never be a start point, since it's a dynamically assigned value.
You may be able to use Javascript to make this work, by setting the proper width after loading the page. For block elements, setting the width to 100% instead of auto
may work as a solution as well.