Reputation: 4148
i'm trying to make simple dice roll effect using HTML symbols. how can i repeat that animation?
looking for simple css solution that i miss.
css part:
.dice { /* HTML symbols */
font-size: 100px;
font-weight: 800;
position: fixed;
opacity: 0;
}
.dice:nth-child(1n) {animation: rolling 1s linear 1s 1 alternate;}
.dice:nth-child(2n) {animation: rolling 1s linear 2s 1 alternate;}
.dice:nth-child(3n) {animation: rolling 1s linear 3s 1 alternate;}
.dice:nth-child(4n) {animation: rolling 1s linear 4s 1 alternate;}
.dice:nth-child(5n) {animation: rolling 1s linear 5s 1 alternate;}
.dice:nth-child(6n) {animation: rolling 1s linear 6s 1 alternate;}
@-webkit-keyframes rolling {
0% {opacity: 0;}
50% {opacity: 1;}
100% {opacity: 0;}
}
and this is the HTML:
<div class="roll">
<span class="dice">⚀</span>
<span class="dice">⚁</span>
<span class="dice">⚂</span>
<span class="dice">⚃</span>
<span class="dice">⚄</span>
<span class="dice">⚅</span>
</div>
Upvotes: 3
Views: 6785
Reputation: 163
.dice { /* HTML symbols */
font-size: 100px;
font-weight: 800;
}
.dice::after {
content:'';
animation: rolling 6s linear infinite;
}
@keyframes rolling {
0% {content:'\2680';}
16.7% {content:'\2681';}
33.4% {content:'\2682';}
51.1% {content:'\2683';}
67.8% {content:'\2684';}
84.5% {content:'\2685';}
100% {content:'\2685';}
}
<span class="dice"></span>
This will be OK for you?
Upvotes: 4