Communityjoews提出了一个问题：Trigger CSS transition on appended element，或许与您遇到的问题类似。
The cause of not animating the newly added element is batching reflows by browsers.
There is another exception of the batching rule. Browser need to calculate the immediate value, if you are trying to access it. One of these values is
offsetWidth. When you are accessing it, the reflow is triggered. Another one is done separately during the actual display. Again, we have two different style values, so we can interpolate them in time.
This is really one of very few occasion, when this behaviour is desirable. Most of the time accessing the reflow-causing properties in between DOM modifications can cause serious slowdown.
The preferred solution may vary from person to person, but for me, the access of
getComputedStyle()) is the best. There are cases, when
setTimeout is fired without styles recalculation in between. This is rare case, mostly on loaded sites, but it happens. Then you won't get your animation. By accessing any calculated style, you are forcing the browser to actually calculate it.