Skip to content

Instantly share code, notes, and snippets.

@tataue
Last active August 11, 2021 04:15
Show Gist options
  • Save tataue/d9ab0d8ed50705f52e38718d6117f710 to your computer and use it in GitHub Desktop.
Save tataue/d9ab0d8ed50705f52e38718d6117f710 to your computer and use it in GitHub Desktop.
[pure css cube] https://jsbin.com/jawuron #cube
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
#default-example {
height: 300px;
width: 300px;
background: linear-gradient(skyblue,khaki);
perspective: 800px;
perspective-origin: 150% 150%;
display: flex;
align-items: center;
justify-content: center;
}
#example-element {
width: 100px;
height: 100px;
perspective: 550px;
transform-style: preserve-3d;
}
.face {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
position: absolute;
backface-visibility: inherit;
font-size: 60px;
color: #fff;
}
.front {
background: rgba(90,90,90,.7);
transform: translateZ(50px);
}
.back {
background: rgba(0,210,0,.7);
transform: rotateY(180deg) translateZ(50px);
}
.right {
background: rgba(210,0,0,.7);
transform: rotateY(90deg) translateZ(50px);
}
.left {
background: rgba(0,0,210,.7);
transform: rotateY(-90deg) translateZ(50px);
}
.top {
background: rgba(210,210,0,.7);
transform: rotateX(90deg) translateZ(50px);
}
.bottom {
background: rgba(210,0,210,.7);
transform: rotateX(-90deg) translateZ(50px);
}
</style>
</head>
<body>
<div id="output" class="output large">
<section id="default-example" class="default-example">
<div id="example-element" class="transition-all" style="">
<div class="face front">1</div>
<div class="face back">2</div>
<div class="face right">3</div>
<div class="face left">4</div>
<div class="face top">5</div>
<div class="face bottom">6</div>
</div>
</section>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment