Created
December 16, 2016 21:46
-
-
Save ohsoren/ba55fdc9de38d784ee3c1fca3fda1738 to your computer and use it in GitHub Desktop.
roulette spin every X seconds
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="rotate-wheel"> | |
<div class="roulette-ball"></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
@use postcss-nested; | |
@use postcss-simple-vars; | |
$wheel-size : 200px; | |
$ball-size : 16px; | |
$ball-align : -8px; | |
$timing : 12s; | |
.rotate-wheel { | |
position: relative; | |
border: 1px solid slateblue; | |
width: $wheel-size; | |
height: $wheel-size; | |
border-radius: $wheel-size; | |
animation: move $timing infinite ease-out; | |
&::before { | |
content: ""; | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
left: 50%; | |
width: 1px; | |
margin-left: -.5px; | |
background-color: slateblue; | |
} | |
&::after { | |
position: absolute; | |
top: -$ball-size; | |
left: 50%; | |
display: block; | |
content: ""; | |
width: 4px; | |
height: 4px; | |
background-color: indianred; | |
z-index: 10; | |
transform: translate(-2px, 0px); | |
} | |
} | |
@keyframes move { | |
0% { | |
transform: rotate(0deg); | |
} | |
15% { | |
transform: rotate(0deg); | |
} | |
45% { | |
transform: rotate(-360deg); | |
} | |
100% { | |
transform: rotate(-360deg); | |
} | |
} | |
.roulette-ball { | |
position: relative; | |
width: inherit; | |
height: inherit; | |
animation: ballspin $timing infinite linear; | |
&::after { | |
position: absolute; | |
top: 1px; | |
left: 50%; | |
display: block; | |
content: ""; | |
width: $ball-size; | |
height: $ball-size; | |
background-color: white; | |
border-radius: $ball-size; | |
z-index: 10; | |
transform: translate($ball-align, 0px); | |
} | |
} | |
@keyframes ballspin { | |
0% { | |
opacity: 0; | |
} | |
4% { | |
opacity: 1; | |
} | |
7% { | |
opacity: 0; | |
} | |
10% { | |
transform: rotate(0deg) translate(0, 0%); | |
opacity: 1; | |
} | |
15% { | |
transform: rotate(0deg) translate(0, 0%); | |
opacity: 1; | |
} | |
30%{ | |
transform: rotate(1260deg) translate(0, 12%); | |
opacity: 1; | |
} | |
50% { | |
opacity: 1; | |
} | |
52.5% { | |
opacity: 0; | |
} | |
100% { | |
transform: rotate(1260deg) translate(0, 12%); | |
opacity: 0; | |
} | |
} | |
html, body { | |
height: 100%; | |
} | |
body { | |
background-color: #333; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment