A Pen by Anand prabhakar on CodePen.
Created
March 14, 2019 23:21
-
-
Save anandprabhakar0507/08a8b1730b33967c8a1763e395786d38 to your computer and use it in GitHub Desktop.
rocket
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
<div class="container"> | |
<div class="planet"></div> | |
<div class="rocket"></div> | |
</div> |
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
.container{ | |
width: 300px; | |
height:300px; | |
margin: 0 auto; | |
position:relative; | |
overflow:hidden; | |
} | |
.planet{ | |
position:absolute; | |
top:0; | |
left:0; | |
width:100%; | |
height:100%; | |
background:url(https://demo.tutorialzine.com/2013/10/css3-features-you-can-finally-use/assets/img/planet.png) no-repeat center center; | |
} | |
.rocket{ | |
position:absolute; | |
top:0; | |
left:0; | |
width:100%; | |
height:100%; | |
background:url(https://demo.tutorialzine.com/2013/10/css3-features-you-can-finally-use/assets/img/rocket.png) no-repeat 50px center; | |
/* Chrome still requires the -webkit- prefix */ | |
-webkit-animation:orbit 2s linear infinite; | |
animation:orbit 2s linear infinite; | |
transition:background-position 0.8s; | |
} | |
.container:hover .rocket{ | |
background-position:80px center; | |
} | |
/* Define the keyframes of the animation */ | |
@-webkit-keyframes orbit { | |
from { | |
-webkit-transform:rotate(0deg);} | |
to { | |
-webkit-transform:rotate(360deg); | |
} | |
} | |
@keyframes orbit { | |
from { | |
transform:rotate(0deg); | |
/* I am including the -webkit-transform properties, because | |
Chrome might start supporting keyframe without prefix in the future, | |
but we can't be certain whether it will support prefix-free transform | |
at the same time */ | |
-webkit-transform:rotate(0deg);} | |
to { | |
transform:rotate(360deg); | |
-webkit-transform:rotate(360deg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment