Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!--
Hover over the houses for animation!
Use Full Page view for the best experience. -->

<div id="title">
	<h2>Greetings from</h2>
	<h1>Santorini</h1>

	<button id="refresh">Create New Pattern</button>

</div>
              
            
!

CSS

              
                :root {
	--cube-size: 600px;
	--color-white: #f5f8ea;
	--color-white-shadow-1: #96c6d9;
	--color-white-shadow-2: #e1eef2;
	--color-blue: #0d5299;
}

* {
	box-sizing: border-box;
	padding: 0;
	margin: 0;
}

body {
	background-color: #eee;
	min-height: 100vh;
	width: 100%;
	overflow: hidden;
	white-space: nowrap;
	background-color: var(--color-white-shadow-1);
}

#title {
	position: absolute;
	z-index: 2000;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	width: 100%;
	height: 100%;
	pointer-events: none;
	border: 30px double var(--color-blue);
	color: var(--color-blue);
	text-shadow: 1px 1px 0 var(--color-white);
}

#title h2 {
	font-family: "Yellowtail", sans-serif;
	padding: 10px 20px 0;
	font-weight: 400;
	font-size: 30px;
	background-color: var(--color-white);
	margin-bottom: -6px;
	line-height: 1;
	z-index: 1;
	border: 6px solid var(--color-blue);
	border-bottom: 0;
}

#title h1 {
	font-size: 70px;
	font-family: "Josefin Sans", cursive;
	text-transform: uppercase;
	font-weight: 600;
	background-color: var(--color-white);
	padding: 20px 20px 0;
	border: 6px solid var(--color-blue);
	margin-bottom: 40px;
}

button {
	font-size: 16px;
	font-family: "Josefin Sans", cursive;
	text-transform: uppercase;
	font-weight: 700;
	padding: 10px 20px 6px;
	color: var(--color-blue);
	background-color: var(--color-white);
	border: 6px solid var(--color-blue);
	transition: all 0.2s;
	cursor: pointer;
}

button:hover {
	box-shadow: 6px 6px var(--color-blue);
}

#title button {
	pointer-events: all;
}

.wrapper {
	width: calc(var(--cube-size) * 1.4);
	height: 100vh;
	display: inline-block;
	position: relative;
	left: calc(var(--cube-size) * -0.75);
	top: calc(var(--cube-size) * -0.35);
}

.container {
	width: calc(var(--cube-size) * 1.4);
	height: calc(var(--cube-size) * 1.2);
	display: flex;
	justify-content: center;
	align-items: center;
	perspective-origin: top center;
	z-index: 1;
	animation: fadein 1s ease;
}

.container:hover {
	transform: rotateY(180deg);
}

@keyframes fadein {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

.container:nth-child(even) {
	transform: translateX(25%);
}

.container:nth-child(odd) {
	transform: translateX(-25%);
}

.cube {
	z-index: 1;
	position: relative;
	width: var(--cube-size);
	height: var(--cube-size);
	transform-style: preserve-3d;
	transform-origin: center;
	display: flex;
	justify-content: center;
	align-items: center;
	transition: all 0.3s ease-in-out;
}

.rotate {
	transform: rotateX(-45deg) rotateY(45deg);
}

.container:hover > .cube {
	transform: rotateX(-45deg) rotateY(-45deg);
}

.container:hover > .cube .front {
	background-color: var(--color-white-shadow-2);
}

.side {
	position: absolute;
	width: 100%;
	height: 100%;
	/*    opacity: 0.9;*/
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 1;
}

.front {
	background-color: var(--color-white-shadow-1);
	transform: translateZ(calc(var(--cube-size) / 2));
	transition: all 0.2s ease;
}

.door-2:before,
.door-2:after {
	content: "";
	width: 25%;
	height: 65%;
	background: var(--color-blue);
	border-radius: calc(var(--cube-size) / 1);
	border-bottom-right-radius: 0;
	border-bottom-left-radius: 0;
	bottom: 0;
	align-self: flex-end;
	border: calc(var(--cube-size) / 22) solid var(--color-white);
	border-bottom: none;
	opacity: 0.8;
	margin: 0 5%;
}

.door-1:before {
	content: "";
	width: 25%;
	height: 65%;
	background: var(--color-blue);
	border-radius: calc(var(--cube-size) / 1);
	border-bottom-right-radius: 0;
	border-bottom-left-radius: 0;
	bottom: 0;
	align-self: flex-end;
	border: calc(var(--cube-size) / 22) solid var(--color-white);
	border-bottom: none;
	opacity: 0.8;
}

.window-2:before,
.window-2:after {
	content: "";
	width: 20%;
	height: 50%;
	background: var(--color-blue);
	border-radius: calc(var(--cube-size) / 1);
	border-bottom-right-radius: 0;
	border-bottom-left-radius: 0;
	bottom: 0;
	border: calc(var(--cube-size) / 22) solid var(--color-white);
	opacity: 0.8;
	margin: 0 5%;
}

.back {
	background-color: var(--color-white-shadow-1);
	transform: translateZ(calc(var(--cube-size) / -2));
}

.left {
	background-color: var(--color-white-shadow-1);
	transform: rotateY(90deg) translateZ(calc(var(--cube-size) / 2));
}

.right {
	background-color: var(--color-white-shadow-2);
	transform: rotateY(-90deg) translateZ(calc(var(--cube-size) / 2));
}

.top {
	background-color: var(--color-white);
	transform: rotateX(90deg) translateZ(calc(var(--cube-size) / 2));
}

.bottom {
	background-color: #64dd17;
	transform: rotateX(-90deg) translateZ(calc(var(--cube-size) / 2));
}

              
            
!

JS

              
                $(document).ready(function () {
	setScene();

	$("#refresh").click(function () {
		setScene();
	});

	function setScene() {
		$(".wrapper").remove();

		var setCubeSize = getRandomInt(100, 40);

		var items = ["door-1", "door-2", "window-2"];
		document.documentElement.style.setProperty("--cube-size", setCubeSize + "px");

		var columnWidth = setCubeSize * 1.4;
		var columnHeight = $(window).height();
		var containerWidth = $(window).width();
		var columnCubeCount = Math.round(columnHeight / (setCubeSize * 1.2));
		var createColumn = Math.round(containerWidth / columnWidth);

		var createColumnCubes = columnCubeCount;
		var createColumns = createColumn;

		for (i = -2; i < createColumns; i++) {
			$("body").append(`<div class="wrapper"></div>`);
		}

		var itemRight = items[Math.floor(Math.random() * items.length)];
		var itemLeft = items[Math.floor(Math.random() * items.length)];

		for (j = -1; j < createColumnCubes; j++) {
			createCube(itemRight, itemLeft);
		}

		function createCube(itemRight, itemLeft) {
			$(".wrapper")
				.append(
					`<div class="container"><div class="cube"><div class="side front"></div><div class="side left ${itemLeft}"></div><div class="side right ${itemRight}"></div><div class="side back"></div><div class="side top"></div><div class="side bottom"></div></div></div>`
				)
				.delay(800)
				.queue(function (next) {
					$(".cube").addClass("rotate");
					next();
				});
		}

		function getRandomInt(min, max) {
			return Math.floor(Math.random() * (max - min + 1)) + min;
		}
		console.log("Cube Size: " + setCubeSize);
		console.log("Column Count: " + createColumns);
		console.log("Cubes per Column: " + createColumnCubes);
	}
});

              
            
!
999px

Console