Create a Simple Keyframe Animation with CSS
📖 Scenario: You want to make a box on a webpage move smoothly from left to right and back again. This will catch the visitor's eye and make your page more lively.
🎯 Goal: Build a CSS animation using @keyframes that moves a square box horizontally across the screen and back continuously.
📋 What You'll Learn
Create a CSS
@keyframes rule named slide that moves an element from left 0 to left 200px and back.Create a CSS class called
box that sets width, height, background color, and position relative.Apply the
slide animation to the box class with a duration of 4 seconds and infinite repetition.Use semantic CSS properties and ensure the animation runs smoothly.
💡 Why This Matters
🌍 Real World
Keyframe animations are used on websites to create smooth movements and transitions that attract user attention and improve user experience.
💼 Career
Web developers often use CSS animations to enhance the look and feel of websites, making them more interactive and visually appealing.
Progress0 / 4 steps