Cube thingy, now fully functional

Developer
Size
3,833 Kb
Views
4,048

How do I make an cube thingy, now fully functional?

Rotate cube using arrow keys. What is a cube thingy, now fully functional? How do you make a cube thingy, now fully functional? This script and codes were developed by Teo Dragovic on 05 January 2023, Thursday.

Cube thingy, now fully functional Previews

Cube thingy, now fully functional - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Cube thingy, now fully functional</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ * { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
html { height: 100%;
}
body { background-image: radial-gradient(#333333, #1a1a1a); overflow: hidden; height: 100%; font-family: sans-serif;
}
.container { position: relative; margin: 100px auto; width: 200px; height: 200px; perspective: 1000px;
}
.cube { position: absolute; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d;
}
.cube .side { position: absolute; display: block; width: 100%; height: 100%; backface-visibility: hidden; box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.2);
}
.cube .side.blue { background-image: radial-gradient(#4a5096, #393e74);
}
.cube .side.pink { background-image: radial-gradient(#944a67, #72394f);
}
.cube .side.aqua { background-image: radial-gradient(#4a8994, #396a72);
}
.cube .side.green { background-image: radial-gradient(#4a944c, #39723b);
}
.cube .side.orange { background-image: radial-gradient(#94764a, #725b39);
}
.cube .side.red { background-image: radial-gradient(#944a4a, #723939);
}
.cube .side.front { transform: rotateX(0deg) translateZ(100px);
}
.cube .side.back { transform: rotateX(180deg) translateZ(100px);
}
.cube .side.right { transform: rotateY(90deg) translateZ(100px);
}
.cube .side.left { transform: rotateY(-90deg) translateZ(100px);
}
.cube .side.top { transform: rotateX(90deg) translateZ(100px);
}
.cube .side.bottom { transform: rotateX(-90deg) translateZ(100px);
}
p { width: 100%; color: #555; text-align: center; line-height: 1.5;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class="container"> <div class="cube"> <div class="side blue front"></div> <div class="side pink back"></div> <div class="side aqua right"></div> <div class="side green left"></div> <div class="side orange top"></div> <div class="side red bottom"></div> </div>
</div>
<p>rotate cube using arrow keys<p> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Cube thingy, now fully functional - Script Codes CSS Codes

* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
html { height: 100%;
}
body { background-image: radial-gradient(#333333, #1a1a1a); overflow: hidden; height: 100%; font-family: sans-serif;
}
.container { position: relative; margin: 100px auto; width: 200px; height: 200px; perspective: 1000px;
}
.cube { position: absolute; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d;
}
.cube .side { position: absolute; display: block; width: 100%; height: 100%; backface-visibility: hidden; box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.2);
}
.cube .side.blue { background-image: radial-gradient(#4a5096, #393e74);
}
.cube .side.pink { background-image: radial-gradient(#944a67, #72394f);
}
.cube .side.aqua { background-image: radial-gradient(#4a8994, #396a72);
}
.cube .side.green { background-image: radial-gradient(#4a944c, #39723b);
}
.cube .side.orange { background-image: radial-gradient(#94764a, #725b39);
}
.cube .side.red { background-image: radial-gradient(#944a4a, #723939);
}
.cube .side.front { transform: rotateX(0deg) translateZ(100px);
}
.cube .side.back { transform: rotateX(180deg) translateZ(100px);
}
.cube .side.right { transform: rotateY(90deg) translateZ(100px);
}
.cube .side.left { transform: rotateY(-90deg) translateZ(100px);
}
.cube .side.top { transform: rotateX(90deg) translateZ(100px);
}
.cube .side.bottom { transform: rotateX(-90deg) translateZ(100px);
}
p { width: 100%; color: #555; text-align: center; line-height: 1.5;
}

Cube thingy, now fully functional - Script Codes JS Codes

var cube = $('.cube'), calc = cube.clone(false);
function applyTransform (transform) { var matrix = calc.css('transform'), composite = transform + ' ' + matrix; calc.css({'transform':composite}).insertAfter(cube); matrix = calc.css('transform'); cube.css({'transform':matrix}); calc.remove();
}
// rotate using arrow keys
$(document).keyup(function(e) {	e.preventDefault();	var key = e.which,	arrow = {left: 37, up: 38, right: 39, down: 40},	t;	switch(key) {	case arrow.left:	t = 'rotateY(-90deg)';	break;	case arrow.right:	t = 'rotateY(90deg)';	break;	case arrow.up:	t = 'rotateX(90deg)';	break;	case arrow.down:	t = 'rotateX(-90deg)';	break;	}	applyTransform(t);
});
Cube thingy, now fully functional - Script Codes
Cube thingy, now fully functional - Script Codes
Home Page Home
Developer Teo Dragovic
Username teodragovic
Uploaded January 05, 2023
Rating 3
Size 3,833 Kb
Views 4,048
Do you need developer help for Cube thingy, now fully functional?

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!

Teo Dragovic (teodragovic) Script Codes
Create amazing love letters 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!