Last active
February 22, 2021 03:58
-
-
Save Rameshwar-ghodke/ac67cae648278266a4238c300bc0ff5b to your computer and use it in GitHub Desktop.
moving bubbles horizontally and vertically using animation css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Bootstrap Example</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style> | |
* { | |
margin: 0; | |
padding: 0; | |
} | |
/* To give the containers | |
in spherical shape */ | |
.dot { | |
border-radius: 50%; | |
} | |
.dot span { | |
position: absolute; | |
display: block; | |
border: 5px; | |
border-radius: 50%; | |
animation: animate 3s ease-in-out infinite; | |
} | |
/*the animation*/ | |
@keyframes animate { | |
0% { | |
transform: translateX(-300px); | |
} | |
50% { | |
transform: translateX(190px); | |
width: -100px; | |
height: +100px; | |
} | |
100% { | |
transform: translateY(-300px); | |
} | |
} | |
/* Each bubble is defined in a | |
separate section */ | |
/* Set the color, opacity, delay and | |
duration(i.e different speed) */ | |
.dot span:nth-child(1) { | |
top: 300px; | |
left: 250px; | |
height: 160px; | |
width: 160px; | |
background-color: yellow; | |
opacity: 0.7; | |
animation-delay: 0.3s; | |
animation-direction: reverse; | |
} | |
.dot span:nth-child(2) { | |
top: 310px; | |
left: 400px; | |
height: 190px; | |
width: 190px; | |
background-color: green; | |
opacity: 0.9; | |
animation-delay: 0.3s; | |
animation-direction: reverse; | |
animation-duration: 2.3s; | |
} | |
.dot span:nth-child(3) { | |
top: 300px; | |
left: 700px; | |
height: 140px; | |
width: 140px; | |
background-color: #a97f58; | |
opacity: 0.9; | |
animation-delay: 0.5s; | |
animation-direction: reverse; | |
animation-duration: 2.6s; | |
} | |
.dot span:nth-child(4) { | |
top: 310px; | |
left: 600px; | |
height: 180px; | |
width: 180px; | |
background-color: red; | |
opacity: 0.9; | |
animation-delay: 0.7s; | |
animation-direction: reverse; | |
animation-duration: 2.3s; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="dot"> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment