Clock

HTML
<div class="container"> <div class="clock"> <div class="side"> <div class="line"></div> </div> <div class="side"> <div class="line"></div> <div class="glas"> <div class="reflex"></div> <div class="t-hours"> <div class="tick-hour"></div> </div> <div class="t-mins"> <div class="tick-min"></div> </div> <div class="t-secs"> <div class="tick-sec"></div> </div> <div class="alarm"> </div> </div> <ul class="secs"> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> <ul class="mins"> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> <ul class="min"> <li><span>12</span></li> <li><span>11</span></li> <li><span>10</span></li> <li><span>9</span></li> <li><span>8</span></li> <li><span>7</span></li> <li><span>6</span></li> <li><span>5</span></li> <li><span>4</span></li> <li><span>3</span></li> <li><span>2</span></li> <li><span>1</span></li> </ul> </div> <div class="side"> <div class="button"></div> </div> <div class="side"> <div class="line"></div> </div> <div class="side"> <div class="line"></div> </div> <div class="side"></div> <div class="shadow"></div> </div> </div>
SCSS
html, body { margin: 0; padding: 0; } html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } .container { width: 300px; height: 300px; margin: 0 auto; position: fixed; perspective: 1200px; top: 50%; left: 50%; transform: translate(-50%, -50%); .clock { position: absolute; width: 100%; height: 100%; transform-style: preserve-3d; transform-origin: center center; transform: rotateX(-15deg) rotateY(-20deg) translateZ(-150px); background: #000; &:after { content: ""; position: absolute; height: 30px; width: 345px; background: linear-gradient(rgba(0,0,0,.2) 0%, rgba(0,0,0,0) 100%); top: 365px; left: -76px; border-radius: 4px 4px 0 0; } h1, p { position: absolute; z-index: 1; text-align: center; width: 100%; color: #ddd; transform: scaleX(-1) rotate(-180deg); font-weight: 100; font-family: Arial; } h1 { top: 160px; font-size: 14px; } p { top: 145px; font-size: 11px; color: #bbb; } .shadow { position: absolute; background: rgba(0,0,0,.8); width: 100%; height: 100%; z-index: 10; transform: rotateX(90deg) translateZ(-150px); box-shadow: -20px 20px 120px 0 rgba(0,0,0,.8); } .glas { position: absolute; left: 20px; top: 20px; right: 20px; bottom: 20px; border-radius: 50%; border: 5px solid #000; box-shadow: 1px 0 4px 0 rgba(255,255,255,.3), inset 0 0 5px #666, inset -20px -10px 120px 0 rgba(100,100,100,.4); } .reflex { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); background: #f6bc0d; width: 30px; height: 30px; z-index: 10; border-radius: 50%; box-shadow: inset -3px 0 0 0 rgba(255,255,255,.5), inset 1px 0 0 0 rgba(0,0,0,.5), 0 -1px 4px 1px rgba(0,0,0,.5); } .t-secs { position: absolute; width: 100%; height: 100%; animation: tick 60s normal infinite steps(60, end); z-index: 5; } .t-mins { position: absolute; width: 100%; height: 100%; animation: tick 3600s normal infinite steps(3600,end); z-index: 4; } .t-hours { position: absolute; width: 100%; height: 100%; animation: tick 21600s normal infinite steps(3600,end); z-index: 3; } .tick-sec { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(120deg); width: 30px; height: 30px; border-radius: 50%; z-index: 5; background: #f6bc0d; &:before, &:after { content: ""; position: absolute; background: #f6bc0d; width: 5px; z-index: 3; transform: translateX(-50%); left: 50%; border-radius: 3px; } &:before { height: 100px; margin-top: -5px; top: 100%; box-shadow: inset -1px 0 0 0 rgba(255,255,255,.5), inset 1px 0 0 0 rgba(0,0,0,.5), 2px 0 0 0 rgba(0,0,0,.8); } &:after { height: 20px; width: 20px; margin-bottom: -5px; bottom: 100%; border-radius: 10px 10px 0 0; box-shadow: inset -1px 0 0 0 rgba(255,255,255,.5), inset 1px 0 0 0 rgba(0,0,0,.5), 2px 0 0 0 rgba(0,0,0,.8); } } .tick-min { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(-30deg); width: 30px; height: 30px; border-radius: 50%; z-index: 2; background: #eee; &:before { content: ""; position: absolute; background: #eee; width: 8px; z-index: 4; transform: translateX(-50%); left: 50%; border-radius: 4px; } &:before { height: 100px; margin-top: -5px; top: 100%; box-shadow: inset -2px 0 0 0 rgba(255,255,255,1), inset 1px 0 0 0 rgba(0,0,0,.5); } } .tick-hour { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(60deg); width: 30px; height: 30px; border-radius: 50%; z-index: 2; background: #fff; &:before { content: ""; position: absolute; background: #eee; width: 12px; z-index: 4; transform: translateX(-50%); left: 50%; border-radius: 6px; box-shadow: inset -4px 0 0 0 rgba(255,255,255,1), inset 1px 0 0 0 rgba(0,0,0,.5); } &:before { height: 80px; margin-top: -5px; top: 100%; } } .alarm { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(-165deg); width: 30px; height: 30px; border-radius: 50%; z-index: 2; background: #000; &:before { content: ""; position: absolute; background: #000; width: 8px; z-index: 4; transform: translateX(-50%); left: 50%; } &:before { height: 70px; margin-top: -5px; top: 100%; border: 1px solid rgba(100,100,100,.5); box-shadow: inset 0 -10px 0 0 #7dab59; } } ul, li { margin: 0; padding: 0; list-style-type: none; z-index: 1; } ul { transform-origin: 50% 50%; position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; border-radius: 50%; margin: -10px 0 0 -10px; border: 1px solid #ccc; } li { position: absolute; width: 20px; height: 20px; font-size: 16px; line-height: 20px; text-align: right; } .secs { li { &:after { content: ""; position: absolute; right: 0; top: 0; background: rgba(255,255,255,.4); width: 5px; height: 2px; } @for $i from 1 through 60 { &:nth-child(#{$i}) { $rotation: 6 * $i; transform: rotate(#{$rotation}deg) translateX(100px); } } } } .mins { li { &:after { content: ""; position: absolute; right: 0; top: 50%; background: #ddd; width: 10px; height: 4px; } @for $i from 1 through 12 { &:nth-child(#{$i}) { $rotation: 30 * $i; transform: rotate(#{$rotation}deg) translateX(100px); } } } } .min { color: #ccc; font-family: Helvetica, sans-serif; font-weight: 100; span { font-size: 13px; display: block; position: absolute; width: 100&; height: 100%; right: 0; top: 0; } li { @for $i from 1 through 12 { &:nth-child(#{$i}) { $rotation: 30 * ($i + 2); transform: rotate(#{$rotation}deg) translateX(80px); $r: $rotation + 180; span { transform: scaleX(-1) rotate(#{$r}deg); } } } } } .side { position: absolute; width: 300px; height: 300px; background: #ddd; border-radius: 10px; &:nth-child(1) { z-index: -1; transform: rotateX(0deg) translateZ(-150px); .line { position: absolute; right: -25%; top: 100%; width: 150%; height: 1px; background: linear-gradient(rgba(0,0,0,.1) 70%, rgba(0,0,0,0) 100%); } } &:nth-child(2) { transform: rotateX(180deg) translateZ(-150px); background: #1b191c; .line { position: absolute; left: -25%; bottom: 100%; width: 150%; height: 1px; background: linear-gradient(rgba(0,0,0,.1) 70%, rgba(0,0,0,0) 100%); } } &:nth-child(3) { transform: rotateX(-90deg) translateZ(-150px); background: linear-gradient(#302f2d 0%, #615b5d 100%); &:after { content: ""; position: absolute; right: 0px; top: 40px; width: 100%; height: 25px; background: #000; border-bottom: 5px solid rgba(255,255,255,.5); } } &:nth-child(4) { transform: rotateY(90deg) translateZ(-150px); .line { position: absolute; left: -40%; top: 100%; width: 200%; height: 1px; background: linear-gradient(rgba(0,0,0,.1) 70%, rgba(0,0,0,0) 100%); } } &:nth-child(5) { transform: rotateY(-90deg) translateZ(-150px); background: linear-gradient(-45deg, #302f2d, #76757b 100%); .line { position: absolute; left: -50%; top: 100%; width: 200%; height: 1px; background: linear-gradient(rgba(0,0,0,.1) 70%, rgba(0,0,0,0) 100%); } &:after { content: ""; position: absolute; right: 40px; border-left: 5px solid rgba(255,255,255,.5); top: 0; width: 25px; height: 100%; background: #000; } &:before { content: ""; position: absolute; left: 0px; top: 100%; width: 95%; height: 30px; background: linear-gradient(rgba(0,0,0,.1) 0%, rgba(0,0,0,0) 100%); } } &:nth-child(6) { transform: rotateX(90deg) translateZ(-150px); } } } .button { position: absolute; width: 50%; border: 5px solid #555; height: 150px; bottom: 0; left: 25%; border-top: 10px solid #000; &:after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); border-radius: 50%; width: 60px; height: 60px; background: #717747; } } } @keyframes tick { 0% { transform: rotate(0deg); } 100% { transform: rotate(-360deg); } }
JAVASCRIPT
Expand for more options Login