cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              $p: 100px;
* { box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: rgba(0,0,0,0); }
body, html { height: 100%; }
body {
	background: $mint;
	display: flex;
	align-items: center;
	align-content: center;
	justify-content: center;
	perspective: 1000px;
	font-family: $body;
	color: $forest;
}

.cube {
	transform: rotateX(-30deg) rotateY(0) translateZ(0);
	transform-origin: $p/2 $p/2 #{-($p/2)};
	transform-style: preserve-3d;
	position: relative;
	width: $p;
	height: $p;
	animation: rotate 8000ms linear infinite;
	div {
		display: flex;
		align-items: center;
		align-content: center;
		justify-content: center;
		position: absolute;
		top: 0;
		left: 0;
		width: $p;
		height: $p;
		background: $forest;
		opacity: 0.75;
		// top
		&:nth-child(1) {
			background: lighten($grey, 15%);
			transform-origin: center top;
			transform: rotateX(90deg) translateY(#{-($p)});
			animation: top-init 4000ms ease-in-out 2, top 4000ms ease-in-out 8000ms infinite;
		}
		// bottom
		&:nth-child(2) {
			background: $beige;
			transform-origin: center bottom;
			transform: rotateX(-90deg) translateY($p);
			animation: bottom-init 4000ms ease-in-out 4, bottom 4000ms ease-in-out 8000ms infinite;
		}
		// left
		&:nth-child(3) {
			background: $green;
			transform-origin: left center;
			transform: rotateY(-90deg) translateX(#{-($p)});
			animation: left-init 4000ms ease-in-out 4, left 4000ms ease-in-out 8000ms infinite;
		}
		// right
		&:nth-child(4) {
			background: mix($green, $beige);
			transform-origin: right center;
			transform: rotateY(90deg) translateX($p);
			animation: right-init 4000ms ease-in-out 4, right 4000ms ease-in-out 8000ms infinite;
		}
		// front
		&:nth-child(5) {
			background: $pink;
			transform-origin: center center;
			transform: rotateX(0);
			animation: front-init 4000ms ease-in-out 4, front 4000ms ease-in-out 8000ms infinite;
		}
		// back
		&:nth-child(6) {
			background: mix($pink, $grey);
			transform-origin: center center;
			transform: rotateY(180deg) translateZ($p);
			animation: back-init 4000ms ease-in-out 4, back 4000ms ease-in-out 8000ms infinite;
		}
	}
}

@keyframes rotate {
	0% { transform: rotateX(0) rotateY(0) rotateZ(0) translateZ(0); }
	100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg) translateZ(0); }
}

@keyframes top {
	0% { transform: rotateX(90deg) translateY(#{-($p)}) translateZ(0); }
	50% { transform: rotateX(90deg) translateY(#{-($p)}) translateZ($p); }
	100% { transform: rotateX(90deg) translateY(#{-($p)}) translateZ(0); }
}

@keyframes top-init {
	0% { transform: rotateX(90deg) translateY(#{-($p)}) translateZ(0); }
	50% { transform: rotateX(90deg) translateY(#{-($p)}) translateZ(#{$p/2}); }
	100% { transform: rotateX(90deg) translateY(#{-($p)}) translateZ(0); }
}

@keyframes bottom {
	0% { transform: rotateX(-90deg) translateY($p) translateZ(0); }
	50% { transform: rotateX(-90deg) translateY($p) translateZ($p); }
	100% { transform: rotateX(-90deg) translateY($p) translateZ(0); }
}

@keyframes bottom-init {
	0% { transform: rotateX(-90deg) translateY($p) translateZ(0); }
	50% { transform: rotateX(-90deg) translateY($p) translateZ(#{$p/2}); }
	100% { transform: rotateX(-90deg) translateY($p) translateZ(0); }
}

@keyframes left {
	0% { transform: rotateY(-90deg) translateX(#{-($p)}) scaleY(1); }
	50% { transform: rotateY(-90deg) translateX(#{-($p)}) scaleY(3); }
	100% { transform: rotateY(-90deg) translateX(#{-($p)}) scaleY(1); }
}

@keyframes left-init {
	0% { transform: rotateY(-90deg) translateX(#{-($p)}) translateZ(0); }
	50% { transform: rotateY(-90deg) translateX(#{-($p)}) translateZ(#{$p/2}); }
	100% { transform: rotateY(-90deg) translateX(#{-($p)}) translateZ(0); }
}

@keyframes right {
	0% { transform: rotateY(90deg) translateX($p) scaleY(1); }
	50% { transform: rotateY(90deg) translateX($p) scaleY(3); }
	100% { transform: rotateY(90deg) translateX($p) scaleY(1); }
}

@keyframes right-init {
	0% { transform: rotateY(90deg) translateX($p) translateZ(0); }
	50% { transform: rotateY(90deg) translateX($p) translateZ(#{$p/2}); }
	100% { transform: rotateY(90deg) translateX($p) translateZ(0); }
}

@keyframes front {
	0% { transform: rotateX(0) scaleY(1); }
	50% { transform: rotateX(0) scaleY(3); }
	100% { transform: rotateX(0) scaleY(1); }
}

@keyframes front-init {
	0% { transform: rotateX(0) translateZ(0); }
	50% { transform: rotateX(0) translateZ(#{$p/2}); }
	100% { transform: rotateX(0) translateZ(0); }
}

@keyframes back {
	0% { transform: rotateY(180deg) translateZ($p) scaleY(1); }
	50% { transform: rotateY(180deg) translateZ($p) scaleY(3); }
	100% { transform: rotateY(180deg) translateZ($p) scaleY(1); }
}

@keyframes back-init {
	0% { transform: rotateY(180deg) translateZ($p) translateZ(0); }
	50% { transform: rotateY(180deg) translateZ($p) translateZ(#{$p/2}); }
	100% { transform: rotateY(180deg) translateZ($p) translateZ(0); }
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console