$foreground: #FFFFFF; $background: #000000; $animation-length: 5s; $animation-delay: $animation-length - 1.7; $slide-count: 6; * { box-sizing: border-box; } body { justify-content: center; align-items: center; background: $background; color: $foreground; font-family: Sans-Serif; margin:0; padding:0; overflow:hidden; animation: colorchange 30s linear alternate infinite; } h1 { margin:0; } .container { height:100vh; width: 100vw; @for $child from 0 to $slide-count - 2 { >:nth-child(#{$child+1}) { animation-delay: $animation-delay*$child; animation-duration: $animation-length; animation-name: slide-in-out; animation-fill-mode: both; } } >:nth-child(#{$slide-count - 1}) { animation-delay: $animation-delay* ($slide-count - 2); animation-duration: $animation-length; animation-name: slide-in-and-move-up; animation-fill-mode: both; } >:nth-child(#{$slide-count}) { animation-delay: $animation-delay* ($slide-count - 1); animation-duration: $animation-length; animation-name: slide-in; animation-fill-mode: both; h2 { margin-bottom: 120px; } } >:nth-child(#{$slide-count + 1}) { animation-delay: $animation-delay* ($slide-count + 1); animation-duration: $animation-length; animation-name: slide-in-last; animation-fill-mode: both; h1 { margin: 120px; } } } .slide { position: absolute; height:100vh; width: 100vw; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; img { max-height: 80vh; } } @keyframes slide-in-out { 0% { transform: translateY(50px); opacity: 0; } 30%, 60% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-50px); opacity: 0; } } @keyframes slide-in-and-move-up { 0% { transform: translateY(50px); opacity: 0; } 30%, 60% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(50px); opacity: 1; } } @keyframes slide-in { 0% { transform: translateY(100px); opacity: 0; } 30%, 100% { transform: translateY(0); opacity: 1; } } @keyframes slide-in-last { 0% { transform: translateY(300px); opacity: 0; } 30%, 100% { transform: translateY(200px); opacity: 1; } } @keyframes colorchange { 0% {background: #01004b;} 33% {background: #002b4a;} 66% {background: #01004b;} 100% {background: #30004b;} }