CSS3 animated wooden box
How do I make an css3 animated wooden box?
Try to rotate it like you are used from your 3D software. What is a css3 animated wooden box? How do you make a css3 animated wooden box? This script and codes were developed by Robert on 08 November 2022, Tuesday.
CSS3 animated wooden box - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS3 animated wooden box</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="hint">Rotate it with your mouse (drag and spin).</div>
<div class="box"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div>
</div> <script src="js/index.js"></script>
</body>
</html>
CSS3 animated wooden box - Script Codes CSS Codes
@-webkit-keyframes openBoxSix { 25% { -webkit-transform: translate3d(0, 1px, -64px) rotateX(90deg); } 45% { -webkit-transform: translate3d(0, 1px, -64px) rotateX(210deg); } 55% { -webkit-transform: translate3d(0, 1px, -64px) rotateX(210deg); } 75% { -webkit-transform: translate3d(0, 1px, -64px) rotateX(90deg); }
}
@-moz-keyframes openBoxSix { 25% { -moz-transform: translate3d(0, 1px, -64px) rotateX(90deg); } 45% { -moz-transform: translate3d(0, 1px, -64px) rotateX(210deg); } 55% { -moz-transform: translate3d(0, 1px, -64px) rotateX(210deg); } 75% { -moz-transform: translate3d(0, 1px, -64px) rotateX(90deg); }
}
@keyframes openBoxSix { 25% { transform: translate3d(0, 1px, -64px) rotateX(90deg); } 45% { transform: translate3d(0, 1px, -64px) rotateX(210deg); } 55% { transform: translate3d(0, 1px, -64px) rotateX(210deg); } 75% { transform: translate3d(0, 1px, -64px) rotateX(90deg); }
}
@-webkit-keyframes openBoxSeven { 25% { -webkit-transform: translate3d(0, 1px, 64px) rotateX(270deg); } 45% { -webkit-transform: translate3d(0, 1px, 64px) rotateX(150deg); } 55% { -webkit-transform: translate3d(0, 1px, 64px) rotateX(150deg); } 75% { -webkit-transform: translate3d(0, 1px, 64px) rotateX(270deg); }
}
@-moz-keyframes openBoxSeven { 25% { -moz-transform: translate3d(0, 1px, 64px) rotateX(270deg); } 45% { -moz-transform: translate3d(0, 1px, 64px) rotateX(150deg); } 55% { -moz-transform: translate3d(0, 1px, 64px) rotateX(150deg); } 75% { -moz-transform: translate3d(0, 1px, 64px) rotateX(270deg); }
}
@keyframes openBoxSeven { 25% { transform: translate3d(0, 1px, 64px) rotateX(270deg); } 45% { transform: translate3d(0, 1px, 64px) rotateX(150deg); } 55% { transform: translate3d(0, 1px, 64px) rotateX(150deg); } 75% { transform: translate3d(0, 1px, 64px) rotateX(270deg); }
}
@-webkit-keyframes openBoxEight { 5% { -webkit-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); } 25% { -webkit-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(210deg); } 75% { -webkit-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(210deg); } 95% { -webkit-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); }
}
@-moz-keyframes openBoxEight { 5% { -moz-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); } 25% { -moz-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(210deg); } 75% { -moz-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(210deg); } 95% { -moz-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); }
}
@keyframes openBoxEight { 5% { transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); } 25% { transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(210deg); } 75% { transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(210deg); } 95% { transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); }
}
@-webkit-keyframes openBoxNine { 5% { -webkit-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); } 25% { -webkit-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(150deg); } 75% { -webkit-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(150deg); } 95% { -webkit-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); }
}
@-moz-keyframes openBoxNine { 5% { -moz-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); } 25% { -moz-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(150deg); } 75% { -moz-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(150deg); } 95% { -moz-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); }
}
@keyframes openBoxNine { 5% { transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); } 25% { transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(150deg); } 75% { transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(150deg); } 95% { transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); }
}
body,
html { height: 100%; padding: 0; margin: 0;
}
body { -webkit-perspective: 800; background: -webkit-radial-gradient(circle, #1b4a7b, #0b2043); background: -moz-radial-gradient(circle, #1b4a7b, #0b2043); background: radial-gradient(circle, #1b4a7b, #0b2043); cursor: move;
}
.hint { position: absolute; top: 0; left: 0; background: rgba(255, 255, 255, 0.7); padding: 5px;
}
.box { position: absolute; top: 50%; left: 50%; width: 128px; height: 128px; margin-top: -64px; margin-left: -64px; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; transform-style: preserve-3d;
}
.box div { position: absolute; width: 128px; height: 128px; background-image: radial-gradient(circle, transparent 50%, rgba(0, 0, 0, 0.5)), url("http://playground.rendro.de/box/assets/images/woodbox.jpg"); background-image: -webkit-radial-gradient(circle, transparent 50%, rgba(0, 0, 0, 0.5)), url("http://playground.rendro.de/box/assets/images/woodbox.jpg"); background-position: 50% 50%; background-size: 128px 128px; background-repeat: repeat;
}
.box div:nth-of-type(1) { -webkit-transform: translate3d(0, 0, 64px); -moz-transform: translate3d(0, 0, 64px); transform: translate3d(0, 0, 64px);
}
.box div:nth-of-type(2) { -webkit-transform: translate3d(0, 0, -64px) rotateY(180deg); -moz-transform: translate3d(0, 0, -64px) rotateY(180deg); transform: translate3d(0, 0, -64px) rotateY(180deg);
}
.box div:nth-of-type(3) { -webkit-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateZ(90deg); -moz-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateZ(90deg); transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateZ(90deg);
}
.box div:nth-of-type(4) { -webkit-transform: translate3d(64px, 0, 0) rotateY(-90deg) rotateZ(90deg); -moz-transform: translate3d(64px, 0, 0) rotateY(-90deg) rotateZ(90deg); transform: translate3d(64px, 0, 0) rotateY(-90deg) rotateZ(90deg);
}
.box div:nth-of-type(5) { -webkit-transform: translate3d(0, 64px, 0) rotateX(-90deg); -moz-transform: translate3d(0, 64px, 0) rotateX(-90deg); transform: translate3d(0, 64px, 0) rotateX(-90deg);
}
.box div:nth-of-type(6) { width: 128px; height: 64px; background-position: 0 0; -webkit-transform-origin: 50% 0; -moz-transform-origin: 50% 0; transform-origin: 50% 0; -webkit-transform: translate3d(0, 1px, -64px) rotateX(90deg); -moz-transform: translate3d(0, 1px, -64px) rotateX(90deg); transform: translate3d(0, 1px, -64px) rotateX(90deg); -webkit-animation: openBoxSix 10s ease-in-out infinite; -moz-animation: openBoxSix 10s ease-in-out infinite; animation: openBoxSix 10s ease-in-out infinite;
}
.box div:nth-of-type(7) { width: 128px; height: 64px; background-position: 0 0; -webkit-transform-origin: 50% 0; -moz-transform-origin: 50% 0; transform-origin: 50% 0; -webkit-transform: translate3d(0, 1px, 64px) rotateX(270deg); -moz-transform: translate3d(0, 1px, 64px) rotateX(270deg); transform: translate3d(0, 1px, 64px) rotateX(270deg); -webkit-animation: openBoxSeven 10s ease-in-out infinite; -moz-animation: openBoxSeven 10s ease-in-out infinite; animation: openBoxSeven 10s ease-in-out infinite;
}
.box div:nth-of-type(8) { width: 128px; height: 64px; background-position: 0 0; -webkit-transform-origin: 50% 0; -moz-transform-origin: 50% 0; transform-origin: 50% 0; -webkit-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); -moz-transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); transform: translate3d(-64px, 0, 0) rotateY(90deg) rotateX(90deg); -webkit-animation: openBoxEight 10s ease-in-out infinite; -moz-animation: openBoxEight 10s ease-in-out infinite; animation: openBoxEight 10s ease-in-out infinite;
}
.box div:nth-of-type(9) { width: 128px; height: 64px; background-position: 0 0; -webkit-transform-origin: 50% 0; -moz-transform-origin: 50% 0; transform-origin: 50% 0; -webkit-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); -moz-transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); transform: translate3d(64px, 0, 0) rotateY(90deg) rotateX(270deg); -webkit-animation: openBoxNine 10s ease-in-out infinite; -moz-animation: openBoxNine 10s ease-in-out infinite; animation: openBoxNine 10s ease-in-out infinite;
}
CSS3 animated wooden box - Script Codes JS Codes
var box = document.getElementsByClassName('box')[0], transform = box.style.webkitTransform || box.style.MozTransform, isMoving = false, startX = startY = 0, angleY = 20, angleX = -20, speedX, speedY, multiplier = 0.5, intermediateTime, endTime;
box.style.webkitTransform = ['rotateX(', angleX, 'deg) rotateY(', angleY, 'deg)'].join("");
box.style.MozTransform = ['rotateX(', angleX, 'deg) rotateY(', angleY, 'deg)'].join("");
var start = function(x, y) { isMoving = true; startX = x; startY = y; lastX = startX; lastY = startY; box.style["-webkit-transition"] = ""; box.style["-moz-transition"] = ""; return false;
}, move = function(x, y) { if (isMoving) { speedY = x / lastX; speedX = y / lastY; angleY -= (lastX - x) * multiplier; angleX += (lastY - y) * multiplier; lastX = x; lastY = y; intermediateTime = +(new Date); box.style.webkitTransform = ['rotateX(', angleX, 'deg) rotateY(', angleY, 'deg)'].join(""); box.style.MozTransform = ['rotateX(', angleX, 'deg) rotateY(', angleY, 'deg)'].join(""); return false; } }, end = function(x, y) { isMoving = false; endTime = +(new Date); return false; };
document.onmousedown = function(e) { return start(e.pageX, e.pageY);
};
document.onmousemove = function(e) { return move(e.pageX, e.pageY);
}
document.onmouseup = function(e) { return end();
};
document.ontouchstart = function(e) { if (e.touches.length == 1) { return start(e.touches[0].pageX, e.touches[0].pageY); }
};
document.ontouchmove = function(e) { if (isMoving && e.touches.length == 1) { return move(e.touches[0].pageX, e.touches[0].pageY); }
};
document.ontouchend = function(e) { return end();
};
Developer | Robert |
Username | rendro |
Uploaded | November 08, 2022 |
Rating | 3 |
Size | 4,289 Kb |
Views | 28,336 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Easy pie chart admin panel | 3,369 Kb |
A Pen by Robert | 3,362 Kb |
CSS Slideshow | 1,847 Kb |
Circular minimal countdown | 4,639 Kb |
WebGL cube test | 15,142 Kb |
CSS3 Browser | 2,882 Kb |
CSS device icons | 2,360 Kb |
3D canvas cube | 2,895 Kb |
Flexbox slider | 3,459 Kb |
Responsive image grid | 2,345 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
TestTube CSS | EZPK | 2,710 Kb |
CSS Colors | Alexpate | 2,232 Kb |
Single element checkbox | Ivijaygupta | 1,996 Kb |
See Through | Larrygeams | 77,410 Kb |
A Pen by Moeid Saleem | Moeidsaleem | 1,862 Kb |
Layout 11 | Altynai | 1,690 Kb |
CSS Org Chart | Appirio-ux | 3,882 Kb |
Fluid Layout with Float | Jxqr97 | 1,785 Kb |
Polygon Logo in CSS | Kai | 3,412 Kb |
CSS Social Media Icon | TychoBlender | 3,871 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!