$max-child: 5; @for $i from 1 through $max-child { * > .enter-x:nth-child(#{$i}) { transform: translateX(50px); } * > .-enter-x:nth-child(#{$i}) { transform: translateX(-50px); } * > .enter-x:nth-child(#{$i}), * > .-enter-x:nth-child(#{$i}) { // z-index: 10 - $i; opacity: 0; animation: enter-x-animation 0.3s ease-in-out 0.2s; animation-delay: 0.1s * $i; animation-fill-mode: forwards; } * > .enter-y:nth-child(#{$i}) { transform: translateY(50px); } * > .-enter-y:nth-child(#{$i}) { transform: translateY(-50px); } * > .enter-y:nth-child(#{$i}), * > .-enter-y:nth-child(#{$i}) { // z-index: 10 - $i; opacity: 0; animation: enter-y-animation 0.3s ease-in-out 0.2s; animation-delay: 0.1s * $i; animation-fill-mode: forwards; } } @keyframes enter-x-animation { to { opacity: 1; transform: translateX(0); } } @keyframes enter-y-animation { to { opacity: 1; transform: translateY(0); } }