BOX ANIMATION

HTML
<!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]> <html class="no-js"> <!--<![endif]--> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>BOX</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/css.css"> </head> <body> <!--[if lt IE 7]> <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p> <![endif]--> <div class="boxwrp"><input type="checkbox" class="animation"> <div class="box-download"> <div class="bands"><a href="http://daug.eu">STUFF</a></div> <div class="fron"></div> <div class="fron backf"><span>????<br>box</span></div> <div class="left"></div> <div class="left backf"><span>☑<br>open</span></div> <div class="back"></div> <div class="righ"></div> <div class="boto"></div> <div class="topl"></div> <div class="topr"></div> <div class="topf"></div> <div class="topb"></div> </div> </div> <script> // const bx = document.getElementsByClassName("box-download")[0]; // const com = window.getComputedStyle(bx).transform // document.addEventListener("click", ()=>{ // const com = window.getComputedStyle(bx).transform // bx.style.transform = "rotateZ(0) rotateX(-25deg)"; // bx.style.animation = "none"; // bx.style.animationPlayState = "paused"; // console.log(com) // }) </script> </body> </html>
CSS
@keyframes scaleshadow { 25% { box-shadow: 0 0 .125em rgba(0, 0, 0, .2), 0 0 .125em rgba(0, 0, 0, .2), -.35em 0 .125em rgba(0, 0, 0, .2), .35em 0 .125em rgba(0, 0, 0, .2) } 50% { box-shadow: 0 0 .125em rgba(0, 0, 0, .2), 0 0 .125em rgba(0, 0, 0, .2), -.25em 0 .125em rgba(0, 0, 0, .2), .25em 0 .125em rgba(0, 0, 0, .2) } 75% { box-shadow: 0 -.35em .125em rgba(0, 0, 0, .2), 0 .35em .125em rgba(0, 0, 0, .2), -.25em 0 .125em rgba(0, 0, 0, .2), .25em 0 .125em rgba(0, 0, 0, .2) } to { box-shadow: 0 -.25em .125em rgba(0, 0, 0, .2), 0 .25em .125em rgba(0, 0, 0, .2), -.25em 0 .125em rgba(0, 0, 0, .2), .25em 0 .125em rgba(0, 0, 0, .2) } } @keyframes topl { to { transform: translateY(-.5em) rotateX(90deg) rotateY(-220deg) } } @keyframes topr { to { transform: translateY(-.5em) rotateX(90deg) rotateY(220deg) } } @keyframes topf { to { transform: translateZ(.5em) rotateZ(90deg) rotateY(130deg) } } @keyframes topb { to { transform: translateZ(-.5em) rotateZ(-90deg) rotateY(120deg) } } @keyframes rotate { to { transform: rotateX(-45deg) rotateY(-305deg) } } @keyframes outs { to { transform: translateY(-90%) scale(1); } } body { margin: 0; overflow-x: hidden; font-size: 16px } .boxwrp { perspective: 400px; margin: 0 auto; position: relative; font: 2.5em/1 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; color: #555; display: block; height: 170px; font-size: 60px; overflow: hidden } .boxwrp span { font-size: 24px; margin: .2em auto; display: block; position: relative } .box-download { position: relative; height: 1em; width: 1em; margin: 1em auto; transform-style: preserve-3d; transform: rotateX(-45deg) rotateY(55deg); text-align: center; -webkit-tap-highlight-color: transparent; user-select: none; transform-origin: center center; animation: rotate 10s linear infinite } .fron { transform: translateZ(.5em) } .back { transform: translateZ(-.5em) } .left { transform: translateX(-.5em) rotateY(-90deg) } .righ { transform: translateX(.5em) rotateY(90deg) } .boto { transform: translateY(.5em) rotateX(90deg) } .topl, .topr { transform: translateY(-.5em) rotateX(90deg) } .topl { transform-origin: left center; z-index: 1 } .topr { transform-origin: right center; right: 0; z-index: 1 } .topf { transform-origin: .5em 0; right: 0; transform: translateZ(.5em) rotateZ(90deg) rotateY(-90deg) } .topb { transform: translateZ(-.5em) rotateZ(-90deg) rotateY(-90deg); transform-origin: 0 0 } .back, .boto, .fron, .left, .righ { overflow: hidden; width: 1em; height: 1em; position: absolute; background: #f7e569; box-sizing: border-box; top: 0 } .back, .fron, .left, .righ { box-shadow: 0 0 .1em#55461f41 inset, .2em .1em .2em .1em #d1be1666 inset } .boto { box-shadow: 0 0 .125em 0 rgba(0, 0, 0, .4) } .topb, .topf, .topl, .topr { overflow: hidden; width: .5em; height: 1em; position: absolute; background: #fff080; box-shadow: 0 0 .1em #55461f41 inset, 0 0 .2em .1em #d1be1666 inset; outline: 1px solid transparent; box-sizing: border-box; top: 0 } input[type="checkbox"] { -webkit-appearance: none; -moz-appearance: none; appearance: none; outline: 0; height: 50%; width: 100%; position: absolute; border: 0; z-index: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; bottom: 0; } .animation:checked+.box-download .topl { animation: topl 2s forwards } .animation:checked+.box-download .topr { animation: topr 2s forwards } .animation:checked+.box-download .topf { animation: topf 2s 1s forwards } .animation:checked+.box-download .topb { animation: topb 2s 1s forwards } .animation:checked+.box-download { transform: rotateZ(0deg) rotateX(-45deg); animation: 0s ease 0s 1 normal none paused none; animation-play-state: paused } .animation:checked+.box-download .boto { animation: scaleshadow 2.5s .5s linear forwards } .animation:checked+.box-download .bands { animation: 3s 1s outs forwards; } .backf { backface-visibility: hidden; background: 0 0; z-index: 1 } .bands { font-size: 16px; height: 100%; width: 100%; transform: translateY(0) scale(0); } .bands p { white-space: nowrap }
JAVASCRIPT
Expand for more options Login