Rotating cube
How do I make an rotating cube?
A two faced cube that rotates when it's clicked. What is a rotating cube? How do you make a rotating cube? This script and codes were developed by Hampus Persson on 13 September 2022, Tuesday.
Rotating cube - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Rotating cube</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <section class="container"> <div id="cube"> <figure class="main">Main</figure> <figure class="secondary">Secondary</figure> </div> </section> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Rotating cube - Script Codes CSS Codes
body { font-family: 'Helvetica Neue', Arial, sans-serif; -webkit-text-size-adjust: none; color: #333; background-color: #333;
}
figure { margin: 0;
}
.container { width: 200px; height: 200px; position: relative; margin: 40px auto; -webkit-perspective: 1000px; -moz-perspective: 1000px; -o-perspective: 1000px; perspective: 1000px;
}
#cube { width: 100%; height: 100%; position: absolute; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -o-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-transition: -webkit-transform 1s; -moz-transition: -moz-transform 1s; -o-transition: -o-transform 1s; transition: transform 1s;
}
#cube figure { display: block; position: absolute; width: 196px; height: 196px; border: 2px solid black; line-height: 196px; font-size: 30px; font-weight: bold; color: white; text-align: center; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; backface-visibility: hidden;
}
#cube .main { background: #F3398B; }
#cube .secondary { background: #1D938C ; }
#cube .main { -webkit-transform: translateZ( 100px ); -moz-transform: translateZ( 100px ); -o-transform: translateZ( 100px ); transform: translateZ( 100px );
}
#cube .secondary { -webkit-transform: rotateX( -90deg ) translateZ( 100px ); -moz-transform: rotateX( -90deg ) translateZ( 100px ); -o-transform: rotateX( -90deg ) translateZ( 100px ); transform: rotateX( -90deg ) translateZ( 100px );
}
#cube.show-secondary { -webkit-transform: translateZ( -100px ) rotateX( 90deg ); -moz-transform: translateZ( -100px ) rotateX( 90deg ); -o-transform: translateZ( -100px ) rotateX( 90deg ); transform: translateZ( -100px ) rotateX( 90deg );
}
Rotating cube - Script Codes JS Codes
$('#cube').on('click', function() { $(this).toggleClass('show-secondary');
});
![Rotating cube - Script Codes](http://shots.codepen.io/hmps/pen/LBmDl-512.jpg)
Developer | Hampus Persson |
Username | hmps |
Uploaded | September 13, 2022 |
Rating | 3 |
Size | 2,161 Kb |
Views | 24,288 |
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 |
Filter list | 3,517 Kb |
Test for pseudo element animation | 3,306 Kb |
The media object | 2,731 Kb |
Rotating cube | 2,161 Kb |
FlowText.js | 3,728 Kb |
Pretty inputs | 2,773 Kb |
Drill down table | 2,989 Kb |
A Pen by Hampus Persson | 1,560 Kb |
Login screen | 3,699 Kb |
Slide like Mailbox | 3,758 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 |
Animated Donut Chart | Jplhomer | 3,808 Kb |
Day 1 - Portfolio | Chpecson | 3,532 Kb |
Update CSS Variables with JS | Wesbos | 2,335 Kb |
Pink expansion tunnel | Vez | 1,738 Kb |
Flat UI - Checkbox FIX | ARS | 2,663 Kb |
SCSS Simple Animated Drop-In | Danwarfel | 2,175 Kb |
Pure CSS candle light animation by One element | Ksksoft | 2,193 Kb |
Super Discount | Orrinward | 3,225 Kb |
SVG email test v2.0 | M_J_Robbins | 2,090 Kb |
Email Marketing Mock | Kristenzirkler | 8,224 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!