Skip to content

Instantly share code, notes, and snippets.

@yoksel
Created September 23, 2013 19:20
Show Gist options
  • Select an option

  • Save yoksel/6675515 to your computer and use it in GitHub Desktop.

Select an option

Save yoksel/6675515 to your computer and use it in GitHub Desktop.
BODY {
perspective: 500px;
perspective-origin: center -5em;
}
.side,
.container {
width: 10em;
height: 10em;
}
.container {
margin: 5em auto 0;
border: 2px dotted white;
transform-style: preserve-3d;
animation: rotate 10s infinite linear;
}
.container:before,
.container:after {
content: "";
display: block;
position: absolute;
width: 10em;
height: 10em;
border: 2px dotted white;
}
.container:before {
transform: rotateX(90deg);
}
.container:after {
transform: rotatey(90deg);
}
.side {
position: absolute;
width: 10em;
height: 10em;
border: 2px solid white;
opacity: .7;
}
.back {
transform: translateZ(-5em);
background: orange;
}
.left {
transform: translateX(-5em) rotateY(90deg);
background: lightgreen;
}
.right {
transform: translateX(5em) rotateY(90deg);
background: yellowgreen;
}
.top {
transform: translateY(-5em) rotateX(90deg);
background: skyblue;
}
.bottom {
transform: translateY(5em) rotateX(90deg);
background: steelblue;
}
.front {
transform: translateZ(5em);
background: gold;
}
@keyframes rotate {
100% {
transform: rotatex(360deg) rotateY(360deg) rotateZ(360deg);
}
}
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div class="container">
<div class="back side"></div>
<div class="left side"></div>
<div class="right side"></div>
<div class="top side"></div>
<div class="bottom side"></div>
<div class="front side"></div>
</div>
</body>
</html>
@yoksel

yoksel commented Sep 23, 2013

Copy link
Copy Markdown
Author

3D cube on Css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment