Design comparison
SolutionDesign
Solution retrospective
What are you most proud of, and what would you do differently next time?
Still im learning a lot about calling API and bettter practice to do so.
What specific areas of your project would you like help with?I tried to make the icon blac dice to spin when click, but coudnt. The styles are there but coudnt make it work.
Community feedback
- @kodan96Posted 5 months ago
hi there ๐
you can define the animation in CSS:
@keyframes rotate { 0% { transform: rotate(0); } 100% { transform: rotate(360deg) } }
then use a helper class to attach the animation when it has the certain class:
.dice.active { animation: rotate 1s linear forwards; }
when
.dice
has the active class it gets animatedThen you can use JS to toggle the class using click eventListener:
dice.addEventListener('click', () => { dice.classList.add('active'); setInterval(() => { dice.classList.remove('active'); }, 500) })
this will add the active class to
.dice
and automatically remove it after 500msHope this was helpful ๐
Good luck and happy coding! ๐
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord