3D Parallax Boxes
How do I make an 3d parallax boxes?
Playing around with 3D transforms and parallax scrolling. Pleasantly surprised with the results.. What is a 3d parallax boxes? How do you make a 3d parallax boxes? This script and codes were developed by Kyle Brumm on 07 January 2023, Saturday.
3D Parallax Boxes - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>3D Parallax Boxes</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <header class="header container"> <h1 class="pen__heading">3D Parallax Boxes</h1> <h4 class="pen__subheading">By: <a href="http://kylebrumm.com" target="_blank">Kyle Brumm</a></h4>
</header>
<main class="main container"> <div class="box-wrap" data-parallax="0.05" data-rotate-x="50" data-rotate-x-speed="0.5" data-rotate-y="10" data-rotate-y-speed="-0.1"> <div class="box box--dark"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="0.1" data-rotate-x="70" data-rotate-x-speed="0.4" data-rotate-y="40" data-rotate-y-speed="0.4"> <div class="box"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="1" data-rotate-x="10" data-rotate-x-speed="0.1" data-rotate-y="80" data-rotate-y-speed="0.8"> <div class="box"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="0.6" data-rotate-x="20" data-rotate-x-speed="0.2" data-rotate-y="20" data-rotate-y-speed="0.4"> <div class="box box--light"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="0.1" data-rotate-x="80" data-rotate-x-speed="0.8" data-rotate-y="45" data-rotate-y-speed="-0.6"> <div class="box box--dark"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="0.7" data-rotate-x="85" data-rotate-x-speed="0.2" data-rotate-y="15" data-rotate-y-speed="0.65"> <div class="box box--light"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="0.1" data-rotate-x="70" data-rotate-x-speed="0.9" data-rotate-y="45" data-rotate-y-speed="0.9"> <div class="box box--dark"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="0.4" data-rotate-x="55" data-rotate-x-speed="1" data-rotate-y="55" data-rotate-y-speed="0.6"> <div class="box box--light"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="0.8" data-rotate-x="35" data-rotate-x-speed="0.3" data-rotate-y="45" data-rotate-y-speed="0.3"> <div class="box"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div> <div class="box-wrap" data-parallax="0.1" data-rotate-x="15" data-rotate-x-speed="0.9" data-rotate-y="65" data-rotate-y-speed="0.3"> <div class="box"> <div class="side front"></div> <div class="side back"></div> <div class="side right"></div> <div class="side left"></div> <div class="side top"></div> <div class="side bottom"></div> </div> </div>
</main> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
3D Parallax Boxes - Script Codes CSS Codes
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400|Raleway:300);
*,
*:before,
*:after { box-sizing: border-box;
}
html { font-family: "Open Sans", Helvetica, arial, sans-serif; color: #333333; background-color: #eeeeee;
}
h1, h2, h3,
h4, h5, h6 { font-family: "Raleway", "Open Sans", sans-serif; text-align: center;
}
a { color: #333333; text-decoration: none;
}
img { max-width: 100%;
}
.header { position: fixed; overflow: visible; width: 100%; max-width: none !important;
}
.header:after { content: ''; position: absolute; bottom: 0; left: 50%; width: 50px; height: 2px; background-color: #9ab59e; -webkit-transform: translateX(-50%); transform: translateX(-50%);
}
.pen__subheading { margin-bottom: 0;
}
.pen__subheading a { color: #9ab59e;
}
.pen__subheading a:hover, .pen__subheading a:focus { color: #c6d5c8;
}
.container { overflow: hidden; width: 100%; max-width: 800px; margin: 0 auto; padding: 2rem 1rem;
}
.col { padding: 1rem;
}
@media (min-width: 800px) { .col { width: 50%; float: left; } .col:nth-of-type(2n+1) { clear: left; }
}
.col.col--full { width: 100%;
}
*,
*:before,
*:after { box-sizing: border-box;
}
.box-wrap { position: relative; display: block; width: 250px; height: 250px; -webkit-perspective: 2000px; perspective: 2000px;
}
.box { position: absolute; width: 100%; height: 100%; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-transform: rotateX(25deg) rotateY(25deg); transform: rotateX(25deg) rotateY(25deg);
}
.box .side { margin: 0; display: block; position: absolute; background-size: cover; background-position: center; -webkit-backface-visibility: hidden; backface-visibility: hidden; border: 2px solid #333333; background-color: #9ab59e;
}
.box .front,
.box .back { width: 251px; height: 251px;
}
.box .right,
.box .left { width: 251px; height: 251px; left: 0px;
}
.box .top,
.box .bottom { width: 251px; height: 251px; top: 0px;
}
.box .front { -webkit-transform: rotateY(0deg) translateZ(125px); transform: rotateY(0deg) translateZ(125px);
}
.box .back { -webkit-transform: rotateY(180deg) translateZ(125px); transform: rotateY(180deg) translateZ(125px);
}
.box .right { -webkit-transform: rotateY(90deg) translateZ(125px); transform: rotateY(90deg) translateZ(125px);
}
.box .left { -webkit-transform: rotateY(-90deg) translateZ(125px); transform: rotateY(-90deg) translateZ(125px);
}
.box .top { -webkit-transform: rotateX(90deg) translateZ(125px); transform: rotateX(90deg) translateZ(125px);
}
.box .bottom { -webkit-transform: rotateX(-90deg) translateZ(125px); transform: rotateX(-90deg) translateZ(125px);
}
body { height: 250vh;
}
.box--light .side { background-color: #c6d5c8;
}
.box--dark .side { background-color: #6e9574;
}
.box-wrap { position: absolute;
}
.box-wrap:nth-of-type(1) { top: 80vh; left: 10vw;
}
.box-wrap:nth-of-type(2) { top: 80vh; left: 38vw;
}
.box-wrap:nth-of-type(3) { top: 80vh; right: 10vw;
}
.box-wrap:nth-of-type(4) { top: 60vh; right: 30vw;
}
.box-wrap:nth-of-type(5) { top: 75vh; right: 0vw;
}
.box-wrap:nth-of-type(6) { top: 90vh; left: 5vw;
}
.box-wrap:nth-of-type(7) { top: 110vh; left: 35vw;
}
.box-wrap:nth-of-type(8) { top: 100vh; right: 10vw;
}
.box-wrap:nth-of-type(9) { top: 70vh; left: 20vw;
}
.box-wrap:nth-of-type(10) { top: 95vh; right: 25vw;
}
3D Parallax Boxes - Script Codes JS Codes
(function($) { var threeD = { // Initialize everything init: function() { this.rotatingBoxes(); }, // Rotate some boxes rotatingBoxes: function() { var $rotate_els = $('.box-wrap'); function updateElementState() { $rotate_els.each(function(idx) { // Parallax var speed = this.dataset.parallax || 0.25; var offset = (-(window.pageYOffset - this.offsetTop) * speed); this.style.transform = 'translate3d(0, ' + offset + 'px, 0)'; this.style.OTransform = 'translate3d(0, ' + offset + 'px, 0)'; this.style.msTransform = 'translate3d(0, ' + offset + 'px, 0)'; this.style.MozTransform = 'translate3d(0, ' + offset + 'px, 0)'; this.style.WebkitTransform = 'translate3d(0, ' + offset + 'px, 0)'; var pageOffset = window.pageYOffset; // X Rotation var initialRotationX = $(this).data('rotate-x') || 25; var rotationSpeedX = $(this).data('rotate-x-speed') || 0; var rotationX = (rotationSpeedX == 0) ? 0 : (-(pageOffset / (rotationSpeedX * 100)) * 10 / 2); var rotateX = rotationX + initialRotationX; // Y Rotation var initialRotationY = $(this).data('rotate-y') || 25; var rotationSpeedY = $(this).data('rotate-y-speed') || 0; var rotationY = (rotationSpeedY == 0) ? 0 : (-(pageOffset / (rotationSpeedY * 100)) * 10 / 2); var rotateY = rotationY + initialRotationY; // Rotate var $child = $(this).find('.box'); $child.css({ '-webkit-transform' : 'rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)', '-moz-transform' : 'rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)', '-ms-transform' : 'rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)', '-o-transform' : 'rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)', 'transform' : 'rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)' }); }); } updateElementState(); $(window).scroll(function() { updateElementState(); }); } } // Run it threeD.init();
})(jQuery);
Developer | Kyle Brumm |
Username | kjbrum |
Uploaded | January 07, 2023 |
Rating | 4.5 |
Size | 5,031 Kb |
Views | 12,144 |
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 |
Wavy Loading Animations | 12,777 Kb |
CSS3 Stylish Checkboxes | 2,624 Kb |
Dotted Menu Concept | 3,327 Kb |
Vue.js Lazy Loading | 3,620 Kb |
_toolbox.scss | 15,452 Kb |
3D Orbiting Split Images | 5,806 Kb |
Stacked Cards Hover Effects | 4,514 Kb |
SVG Hover Animations | 10,557 Kb |
Line Button Hover Effects | 3,930 Kb |
CSS Only Dropdown | 2,655 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 |
Fluid Responsive Typography | Jonmilner | 4,205 Kb |
Experiments with Vertical Centering | KatieK2 | 3,924 Kb |
Wikipedia Viewer | Thalpha | 4,426 Kb |
Brian The CSS Bee | Jonitrythall | 3,922 Kb |
Header | Er40 | 1,542 Kb |
Review test | Otro_user_gil | 4,054 Kb |
NT Tribute | Skybutterfly | 2,850 Kb |
Typefaces with descriptions | Megandoty | 2,944 Kb |
Simple Responsive Text | Fbrz | 2,282 Kb |
Clock Face Idea | Chrisburnell | 3,196 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!