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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="container">
	
	<div class="compositions">
	
		<div class="composition composition--3">
			<div class="frame">
				<div class="frame__face frame__face--front">
					<div class="cell cell1"></div>
					<div class="cell cell2"></div>
					<div class="cell cell3"></div>
					<div class="cell cell4"></div>
					<div class="cell cell5"></div>
					<div class="cell cell6"></div>
					<div class="cell cell7"></div>
					<div class="cell cell8"></div>
					<div class="cell cell9"></div>
					<div class="frame-grad"></div>
					<div class="frame-shad"></div>
				</div>
				<div class="frame__face frame__face--back"></div>
				<div class="frame__face frame__face--left"></div>
				<div class="frame__face frame__face--right"></div>
				<div class="frame__face frame__face--top"></div>
				<div class="frame__face frame__face--bottom"></div>
			 </div>
			<p class="composition__title">Composition III</p>
		</div>
		
		<div class="composition composition--c">
			<div class="frame">
				<div class="frame__face frame__face--front">
					<div class="cell cell1"></div>
					<div class="cell cell2"></div>
					<div class="cell cell3"></div>
					<div class="cell cell4"></div>
					<div class="cell cell5"></div>
					<div class="cell cell6"></div>
					<div class="cell cell7"></div>
					<div class="cell cell8"></div>
					<div class="cell cell9"></div>
					<div class="frame-grad"></div>
					<div class="frame-shad"></div>
				</div>
				<div class="frame__face frame__face--back"></div>
				<div class="frame__face frame__face--left"></div>
				<div class="frame__face frame__face--right"></div>
				<div class="frame__face frame__face--top"></div>
				<div class="frame__face frame__face--bottom"></div>
			 </div>
			<p class="composition__title">Composition C</p>
		</div>
		
		<div class="composition composition--2">
			<div class="frame">
				<div class="frame__face frame__face--front">
					<div class="cell cell1"></div>
					<div class="cell cell2"></div>
					<div class="cell cell3"></div>
					<div class="cell cell4"></div>
					<div class="cell cell5"></div>
					<div class="cell cell6"></div>
					<div class="cell cell7"></div>
					<div class="cell cell8"></div>
					<div class="cell cell9"></div>
					<div class="frame-grad"></div>
					<div class="frame-shad"></div>
				</div>
				<div class="frame__face frame__face--back"></div>
				<div class="frame__face frame__face--left"></div>
				<div class="frame__face frame__face--right"></div>
				<div class="frame__face frame__face--top"></div>
				<div class="frame__face frame__face--bottom"></div>
			 </div>
			<p class="composition__title">Composition II</p>
		</div>
		
	</div>
	<div class="title">
		<h1>Mondrian</h1>
		<p>CSS Grid Compositions</p>
	</div>

</div>


[[[https://codepen.io/petebarr/pen/2fc0573674b0f849badd58a15371534e]]]
            
          
!
            
              
$width: 250px;
$height: $width;
$depth: 25px;
$gridNum: 200;
$white: #ecede8;
$red: #c62f24;
$frameEdge: #e2e3dc;

html {
	box-sizing: border-box;
}
*,
*:before,
*:after {
	box-sizing: inherit;
}

body {
	background: #fdfff3;
	// background: linear-gradient(top, rgba(white,1) 0%, rgba(#fdfff3,1) 100%); 
	color: black;
	font-family: 'Cormorant Garamond', serif;

}

body,
html {
	height: 100%;
	width: 100%;
	margin: 0;
	padding: 0;
}

h1,
p {
	text-transform: uppercase;
	letter-spacing: 2px;
}

h1 {
	font-size: 32px;
	margin: 0;
}

p {
	font-size: 12px;
	margin: 0;
}

.container {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 100%;
}

.compositions {
	display: flex;
}

.composition {
	// margin: 100px;
	width: $width;
	height: $height;
	perspective: 900px;
	margin: 0 $width/10;
}
.frame {
	position: relative;
	width: $width;
	height: $height;
	transform-style: preserve-3d;
	transform: rotateY(0deg);
}
.frame__face {
	position: absolute;
	display: grid;
}
.frame-grad {
	position: absolute;
	z-index: 1;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: linear-gradient(top, rgba(#fff,1) 0%, rgba(#fff,0) 50%); 
	opacity: 0.5;
	mix-blend-mode: overlay;
}
.frame-shad {
	position: absolute;
	z-index: 1;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: black;
	opacity: 0;
}
.frame__face--front {
	display: grid;
	grid-template-columns: repeat($gridNum, 1fr);
	grid-template-rows: repeat($gridNum, 1fr);
	width: $width;
	height: $height;
	background: black;
	transform: translate3d(0, 0, $depth/2);
}
.frame__face--back {
	width: $width;
	height: $height;
	transform: rotateY(180deg) translate3d(0, 0, $depth/2);
	background: white;
	box-shadow: 0px 16px 60px 0 rgba(0, 0, 0, 0.4);

}
.frame__face--left {
	width: $depth;
	height: $height;
	transform: rotateY(-90deg) translate3d(0, 0, $depth/2);
	background: $frameEdge;
}
.frame__face--right {
	width: $depth;
	height: $height;
	transform: rotateY(90deg) translate3d(0, 0, ($width - $depth/2));
	background: $frameEdge;
}
.frame__face--top {
	width: $width;
	height: $depth;
	transform: rotateX(90deg) translate3d(0, 0, $depth/2);
	background: white;
}
.frame__face--bottom {
	width: $width;
	height: $depth;
	transform: rotateX(-90deg) translate3d(0, 0, ($height - $depth/2));
	background: #bfc1b9;
}

.title {
	margin-top: 80px;
	text-align: center;
}

.composition__title {
	text-align: center;
	margin-top: 16px;
	font-size: 10px;
	letter-spacing: 1px;
	opacity: 0.5;
}


/*  ==========================================================================
	Composition 3
	========================================================================== */  

	.composition--3 {
		
		.frame__face--front {
			// background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/61488/composition-3.jpg') no-repeat;
			// background-size: cover;
		}
		
		.cell1 {
			background: $red;
			grid-column: 1 / span 85;
    		grid-row: 1 / span 108;
		}
		
		.cell2 {
			background: $white;
			grid-column: span 112 / 201;
    		grid-row: 1 / span 108;
		}
		
		.cell3 {
			background: $white;
			grid-column: 1 / span 85;
			grid-row: 113 / 201;
		}
		
		.cell4 {
			background: #eeeee4;
			grid-column: 89 / 184;
    		grid-row: 113 / 192;
		}
		
		.cell5 {
			background: #ffd700;
			grid-column: 89 / span 52;
    		grid-row: 196 / 201;
		}
		
		.cell6 {
			background: #24468e;
			grid-column: 188 / 201;
    		grid-row: 113 / 146;
		}
		
		.cell7 {
			background: #eeeee4;
			grid-column: 188 / 201;
    		grid-row: 152 / 201;
		}
		
	}

/*  ==========================================================================
	Composition C
	========================================================================== */  

	.composition--c {
		
		.frame__face--front {
			// background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/61488/composition-c.jpg') no-repeat;
			// background-size: cover;
			// background: black;
		}
		
		.cell1 {
			background: $red;
			grid-column: 1 / span 92;
			grid-row: 1 / span 80;
		}
		
		.cell2 {
			background: $white;
			grid-column: span 105 / 201;
			grid-row: 1 / span 80;
		}
		
		.cell3 {
			background: $white;
			grid-column: 1 / span 92;
			grid-row: 85 / 129;
		}
		
		.cell4 {
			background: $white;
			grid-column: span 105 / 201;
			grid-row: 85 / 129;
		}
		
		.cell5 {
			background: #ffd700;
			grid-column: 1 / span 19;
			grid-row: 133 / 201;
		}
		
		.cell6 {
			background: $white;
			grid-column: 23 / span 70;
			grid-row: 133 / 201;
		}
		
		.cell7 {
			background: #20176e;
			grid-column: 96 / span 60;
			grid-row: 133 / 190;
		}
		
		.cell8 {
			background: $white;
			grid-column: 96 / span 60;
			grid-row: 194 / 201;
		}
		
		.cell9 {
			background: $white;
			grid-column: span 42 / 201;
			grid-row: 133 / 201;
		}
		
	}


/*  ==========================================================================
	Composition 2
	========================================================================== */  

	.composition--2 {
		
		.frame__face--front {
			// background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/61488/composition-2.jpg') no-repeat;
			// background-size: cover;
		}
		
		.cell1 {
			background: $white;
			grid-column: 1 / span 43;
    		grid-row: 1 / span 61;
		}
		
		.cell2 {
			background: $red;
			grid-column: span 151 / 201;
    		grid-row: 1 / span 146;
		}
		
		.cell3 {
			background: $white;
			grid-column: 1 / span 43;
    		grid-row: 74 / 146;
		}
		
		.cell4 {
			background: #015b9a;
			grid-column: 1 / span 43;
    		grid-row: 152 / 201;
		}
		
		.cell5 {
			background: $white;
			grid-column: 50 / 180;
    		grid-row: 152 / 201;
		}
		
		.cell6 {
			background: $white;
			grid-column: 186 / 201;
    		grid-row: 152 / span 21;
		}
		
		.cell7 {
			background: #f0de6e;
			grid-column: 186 / 201;
    		grid-row: 182 / 201;
		}
		
	}

            
          
!
            
              
$('.frame').mousemove(function(e) {
	
	var xPos = $(this).position().left;
	var yPos = $(this).position().top;
	
	var mouseX = e.pageX;
	var mouseY = e.pageY;
	
	var left = e.pageX - xPos;
	var xOffset = left - $(this).width()/2;
	var top = e.pageY - yPos;
	var yOffset = top - $(this).height()/2;
	var xPerc = (xOffset/$(this).width()) * 200;
	var yPerc = (yOffset/$(this).height()) * 200;
		
	TweenMax.to($(this), 2, {
		rotationX: 0.3 * yPerc,
		rotationY: -0.3 * xPerc,
		transformOrigin: "center center -30",
		ease: Expo.easeOut
	});
	
	TweenMax.to($(this).find('.frame-grad'), 2, {
		opacity: top/$(this).height(),
		ease: Expo.easeOut
	});
	
	TweenMax.to($(this).find('.frame-shad'), 2, {
		opacity: 0.15 - top/$(this).height()/2,
		ease: Expo.easeOut
	});
	
});

$('.frame').on('mouseleave', function(){
	TweenMax.to($(this), 2, {
		rotationX: 0,
		rotationY: 0,
		transformOrigin: "center center -20",
		ease: Expo.easeOut
	});
	TweenMax.to($(this).find('.frame-grad'), 2, {
		opacity: 0.5,
		ease: Expo.easeOut
	});
	TweenMax.to($(this).find('.frame-shad'), 2, {
		opacity: 0,
		ease: Expo.easeOut
	});
});

console.clear();

/*  ==========================================================================
    Greensock Dev Tools
    ========================================================================== */  

//instantiate GSDevTools with default settings
// GSDevTools.create( );
            
          
!
999px

Console