My entry for the 17th day of the
month of code.
The theme for today is: random.
Here’s a CSS 3D die. Webkit-only (it’s late and I am lazy).
Code after the break.
1 2 3 4 5 6 7 8 9 10
| <div id="moc-17"> <div id="die"> <div class="face">⚀</div> <div class="face">⚁</div> <div class="face">⚂</div> <div class="face">⚃</div> <div class="face">⚄</div> <div class="face">⚅</div> </div> </div>
|
random.cssview raw1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| @-webkit-keyframes spin { from { -webkit-transform: rotateX(0deg) rotateY(0deg); } to{ -webkit-transform: rotateX(360deg) rotateY(360deg); } }
@keyframes spin { from { transform: rotateX(0deg) rotateY(0deg); } to{ transform: rotateX(360deg) rotateY(360deg); } }
#moc-17 { margin : 150px auto; font-family: sans-serif; font-size: 200px; text-align: center; line-height: 200px;
-webkit-perspective : 1000px; perspective : 1000px; -webkit-perspective-origin : 50% 50%; perspective-origin : 50% 50%; }
#die { position: relative; margin: 0 auto; height: 200px; width: 200px;
-webkit-animation : spin 10s infinite linear; animation : spin 10s infinite linear; -webkit-transform-style : preserve-3d; transform-style : preserve-3d; }
#die .face { position: absolute; height: 200px; width: 200px; opacity: 0.8; background-color: white; border-radius: 50px; border: 1px solid black; }
#die .face:nth-child(1) { -webkit-transform : translateZ(100px); transform : translateZ(100px); }
#die .face:nth-child(2) { -webkit-transform : rotateY(90deg) translateZ(100px); transform : rotateY(90deg) translateZ(100px); }
#die .face:nth-child(3) { -webkit-transform : rotateY(180deg) translateZ(100px); transform : rotateY(180deg) translateZ(100px); }
#die .face:nth-child(4) { -webkit-transform : rotateY(-90deg) translateZ(100px); transform : rotateY(-90deg) translateZ(100px); }
#die .face:nth-child(5) { -webkit-transform : rotateX(-90deg) translateZ(100px) rotate(180deg); transform : rotateX(-90deg) translateZ(100px) rotate(180deg); }
#die .face:nth-child(6) { -webkit-transform : rotateX(90deg) translateZ(100px); transform : rotateX(90deg) translateZ(100px); }
|