$cloud_width: 200px; body { margin: 0; padding: 0; .top { background-image: linear-gradient(#24d3ff, #aaeeff); height: 70vh; } .bottom { background-image: linear-gradient(#26a4c4, #afdde9); height: 30vh; } .clouds { position: absolute; width: $cloud_width; animation-name: move_right; animation-direction: alternate; animation-iteration-count: infinite; animation-timing-function: linear; } #cloud1 { top: $cloud_width / 466 * 70; // 1 cloud worth of gap left: 0; animation-duration: 17s; } #cloud2 { top: $cloud_width / 466 * 70 * 4; // 4 clouds worth of gap left: 0; animation-delay: -2s; animation-duration: 15s; transform: rotateY(180deg); } } @keyframes move_right { from {left: 0} to {left: calc(100vw - #{$cloud_width})} } @keyframes move_left { from {right: 0} to {right: calc(100vw - #{$cloud_width})} }