A Pen by Marian Ban on CodePen.
Created
January 16, 2020 20:24
-
-
Save marianban/1cc676bde0e4e59ef9a3a0f978bf0349 to your computer and use it in GitHub Desktop.
Jumping Boxes
This file contains 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="item item-1">item-1</div> | |
<div class="item item-4">item-2</div> | |
<div class="item item-2">item-2</div> | |
<div class="item item-3">item-3</div> | |
</div> |
This file contains 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
body { | |
background: repeating-linear-gradient( | |
to right, | |
transparent, | |
transparent 10%, | |
#eee 10%, | |
#eee 20%); | |
} | |
.container { | |
position: absolute; | |
top: 30%; | |
left: 10%; | |
display: flex; | |
align-items: flex-end; | |
} | |
$radius: 6em; | |
.item.item-2 { | |
animation-name: none; | |
transform: translateX(300%); | |
height: 30px; | |
} | |
.item.item-4 { | |
animation-name: none; | |
transform: translateX(0%); | |
height: 30px; | |
} | |
.item { | |
height: $radius; | |
width: $radius; | |
background-color: #666; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
animation-duration: 2s; | |
animation-name: jump; | |
animation-iteration-count: infinite; | |
animation-direction: alternate; | |
animation-delay: 0s; | |
animation-timing-function: ease-in; | |
margin-right: 4em; | |
} | |
@keyframes jump { | |
0% { transform: rotate(-1turn) } | |
50% { | |
transform: translate(150%, -100%) rotate(0.5turn); | |
animation-timing-function: ease-out; | |
} | |
100% { transform: translate(300%, 0) rotate(1turn) } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment