Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<style>
* {
margin: 0px;
padding: 0px;
}
html, body {
width: 100%;
height: 100%;
}
.cube {
width: 100px;
height: 100px;
position: relative;
transform-style: preserve-3d;
transform: rotateX(-20deg) rotateY(-45deg);
top: 50%;
left: 50%;
margin-left: -100px;
margin-top: -100px;
}
.cube div {
width: 100px;
height: 100px;
position: absolute;
background: orange;
border: 2px solid black;
box-shadow: inset 0px 0px 30px rgba(0, 0, 0, 0.6);
border-radius: 5px;
}
.cube div.top_side {
transform: rotateX(90deg);
margin-top: -50px;
background-size: 100px 100px;
}
.cube div.right_side {
transform: rotateY(90deg);
margin-left: 50px;
background-size: 100px 100px;
}
.cube div.bottom_side {
transform: rotateX(90deg);
margin-top: 50px;
background-size: 100px 100px;
}
.cube div.left_side {
transform: rotateY(-90deg);
margin-left: -50px;
background-size: 100px 100px;
}
.cube div.front_side {
transform: translateZ(50px);
background-size: 100px 100px;
}
.cube div.back_side {
transform: translateZ(-50px);
}
</style>
</head>
<body>
<script>
$(document).ready(function () {
$(document).keydown(function (e) {
switch (e.which) {
case 37:
$(".cube").animate({ 'marginLeft': "-=10px" });//left arrow key
break;
case 38:
$(".cube").animate({ 'marginTop': "-=10px" }); //up arrow key
break;
case 39:
$(".cube").animate({ 'marginLeft': "+=10px" }); //right arrow key
break;
case 40:
$(".cube").animate({ 'marginTop': "+=10px" }); //bottom arrow key
break;
}
});
});
</script>
<div class="cube">
<div class="top_side"></div>
<div class="right_side"></div>
<div class="bottom_side"></div>
<div class="left_side"></div>
<div class="back_side"></div>
<div class="front_side"></div>
</div>
</body>
</html>
The most helpful JQUERY solutions