How can CSS be used to create an infinite scrolling background animation?

Instruction: Describe the process of creating an infinite scrolling background using only CSS animations.

Context: This question probes the candidate's ability to employ CSS animations in creative ways, specifically to achieve the effect of an endlessly scrolling background.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

A seamless loop moves a repeating pattern by exactly one rendered tile period. This CSS-only example uses an 80px gradient tile, so its endpoint at -80px has the same appearance as its start.

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS example</title> <style> .scene { height: 80px; background: repeating-linear-gradient(90deg, #ddd 0 40px, #999 40px 80px); background-size: 80px 100%; animation: scroll 4s linear...

Related Questions