Introduction
In this project, you will learn how to create a CSS animation that simulates the Earth's orbit around the Sun. This project will help you understand the concepts of CSS animations and how to apply them to create a dynamic and visually engaging web experience.
👀 Preview

🎯 Tasks
In this project, you will learn:
- How to set up the animation for the
.earth-conelement - How to use the
@keyframesfor theorbitanimation to create the Earth's rotation around the center
🏆 Achievements
After completing this project, you will be able to:
- Create a CSS animation that simulates the Earth's orbit around the Sun
- Understand the concepts of CSS animations and how to apply them to create dynamic and visually engaging web experiences
- Coordinate multiple CSS properties to achieve the desired animation effect
Set Up the Project Structure
To get started, open the experiment environment, and the directory structure is as follows:
├── css
│ └── style.css
└── index.html
Where:
index.htmlis the main page.css/style.cssis the CSS file where you need to add code.
Click on Go Live button in the bottom right corner of WebIDE, to run the project.
Next, open the "Web 8080" on the top of the VM and manually refresh the page to see the following effect in your browser:

Set Up the Animation
In this step, you will learn how to add the animation to the .earth-con element in the css/style.css file.
Open the
css/style.cssfile in the code editor, slide to the bottom of the code and you can see thatorbitis the @keyframes rule already given and this@keyframesrule defines the animation sequence.Locate the
.earth-conclass in the CSS file.Inside the
.earth-conclass, add the following CSS properties to define the animation:animation: orbit 36.5s linear infinite;animation-name:orbitanimation-duration:36.5sanimation-timing-function:linearanimation-iteration-count:infinite
This will make the .earth-con element rotate around the center of the screen, simulating the Earth's orbit around the Sun.
- Save the
style.cssfile. - Go back to your browser and refresh the page. You should see the following effect:

Summary
Congratulations! You have completed this project. You can practice more labs in LabEx to improve your skills.



