Coding task · HTML and CSS course · Module 6: CSS Animations

Sliding Element Animation

translateX() moves an element horizontally (positive values = right, negative = left). You can use vw (viewport width) for movement across the entire screen. The 'alternate' animation makes the barque return!

Task

Create @keyframes sail: 0% { translateX(-100px) }, 100% { translateX(100vw) }. Apply to .boat: animation: sail 8s linear infinite. Add direction: alternate so the barque returns. Result: the barque sails both ways!