As part of the gamification process, I am trying to develop an animated raffle based on random numbers (connected to random CSS variables) and prizes/boosters.
This is the first result, any suggestion is welcome!
Sorry for the video quality, donβt know how to add a video here
So any line of the Raffle table is a prize (or nothing), there are 2 list (one with super powers and one without, but the mechanism is the same)
WinState = for visibility purpose
WinPrize = some text
CSS Values > see below
CSS = the formula to create the CSS
The CSS is pretty easy
3 columns of table with different images, icons, text, whatever you like
the animation will move the 3 columns to reach a Value β¦ the value is what you want to show in the line.
So letβs make an example
line 1 > prize 1 > 3 gifts icons (or WIN text) > you have to stop the animation at the right element of the table (for me 6 or 11)
This is the CSS code
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.base{
height: 100px;
display: flex;
align-items: center;
justify-content: center;
}
table{
border-collapse: collapse;
}
tr{height: 100px;}
.letter-one, .letter-two, .letter-three{
height: 100px; /* size of the "central" box */
overflow: hidden; /* This is the trick, if you remove this line you will see the columns */
text-align: center;
display: flex; /* we want to see columns "aligned" vertically */
flex-direction: column;
font-size: 90px; /* size of the icon, text */
background-color: #c5eceb; /* color of the box */
}
.letter-one tr{
--ch:-11; /* This is the stop point for column 1, you can control it through CSS Values in the table */
animation: scroll 1s 1s linear forwards;
}
.letter-two tr{
--ch:-6; /* This is the stop point for column 2, you can control it through CSS Values in the table */
animation: scroll 3s 1s linear forwards;
}
.letter-three tr{
--ch:-6; /* This is the stop point for column 3, you can control it through CSS Values in the table */
animation: scroll 2s 1s linear forwards;
}
@keyframes scroll {
to{
transform: translateY(calc(var(--ch) * 100%));
}
}
And the HTML generated is like this (you need to create 3/4/5β¦ how many columns you like
Here is the full code, just copy/past in a Rich text and it will work
No comments here sorry, but you can follow the code in the previous post.
I added a bit of padding to see part of the previous and next icon/text and borders.
Later I will try to add an image overlay to make it more professional
Happy to read about it, I started with your video about gamifying the experience. Honored to give something back.
And by the way, the Win animation and the card, have a delay (4s) >= to the time you need to reach the final state in the slot/raffle (3,5s) , so the effect will be⦠suspense (slot), result, new animation