Problem:
You set the opacity to 1 at the same time that you created the element.
Decision:
You need to postpone the action showing the element, you need to set the opacity during the timeout to make the animation effect, otherwise all the elements will just be added.
You can see this snippet that I used setTimout to make an opaque animation effect:
//css #a{ width:200px; background-color:salmon; margin:0px; padding:0px; height:200px; overflow: auto; } #a .item{ margin:0px 5px; background-color:teal; padding:10px; color:white; opacity:0; transition:opacity .5s ease-in-out; }
<div id="a"> <div style="height:20px"></div> </div>
source share