Rotating cube

Size
2,161 Kb
Views
24,288

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 Previews

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
Rotating cube - Script Codes
Home Page Home
Developer Hampus Persson
Username hmps
Uploaded September 13, 2022
Rating 3
Size 2,161 Kb
Views 24,288
Do you need developer help for Rotating cube?

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!

Hampus Persson (hmps) Script Codes
Create amazing web content with AI!

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!