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

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

              
                <!-- Needs a device that supports device orientation and should load in debug mode  - https://cdpn.io/mandymichael/debug/JjPwMNW  -->

<div id="page">
	<h1 class="square" id="text" data-splitting>Jello</h1>
</div>

<div class="controls">
	<p class="msg"><a href="https://twitter.com/Mandy_Kerr/status/1176478770686906368?s=20">See the video on twitter</a></p>
	<button id="ios-trigger" class="button" type="button">Make it work for iOS13 </button>

	<button id="click-trigger" class="button" type="button">Add Scale Transform</button>
</div>

              
            
!

CSS

              
                
$red: #f98ca4;
$darkred: #9e132c;
$darkblue: #2f3e9c;
 
body {
	letter-spacing: 0.062rem;
	background: #c2f9cb;
}

h1 {
	font-size: 30vw;
	margin: 0;
	font-family: 'Crimson Pro';
	text-transform: uppercase;
	color: #52d9da;
	text-shadow: 
			-1px -1px 0 $darkblue, 
			1px -1px 0 $darkblue, 
			-1px 1px 0 $darkblue, 
			1px 1px 0 $darkblue, 
			1px 0px 0px $red, 
			0px 1px 0px $red, 
			2px 1px 0px $red, 
			1px 2px 0px $red, 
			3px 2px 0px $red, 
			2px 3px 0px $red, 
			4px 3px 0px $red, 
			3px 4px 0px $red, 
			5px 4px 0px $red,
			3px 5px 0px $darkblue, 
			6px 5px 0px $darkblue, 
			-1px 2px 0 black, 
			0 3px 0 $darkblue, 
			1px 4px 0 $darkblue, 
			2px 5px 0px $darkblue,
			2px -1px 0 $darkblue, 
			3px 0 0 $darkblue, 
			4px 1px 0 $darkblue, 
			5px 2px 0px $darkblue, 
			6px 3px 0 $darkblue, 
			7px 4px 0 $darkblue, 
			10px 10px 4px rgba(#6af177, .8);
}

.splitting .char {
	--weight: 200;
	font-weight: var(--weight);
	display: inline-block;
	transition: all 250ms cubic-bezier(.64,.57,.67,1.53);
}

.transform .splitting .char {
	--transform: 1;
	transform: scale(var(--transform));
}


#page {
	--position: 50%;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100vh;
	font-size: 20vw;
}

// Toggle
$body-color: #c2f9cb;
$text-color: $darkred;

.controls {
	position: absolute;
	bottom: 10px;
	z-index: 100;
	display: block;
	width: 100%;
	text-align: center;
}

.button {
	border: 1px solid $darkblue;
	padding: 10px;
	background: #c2f9cb;
	color: $darkblue;
	font-size: 12px;
	text-transform: uppercase;
	font-weight: 200;
	width: 190px;
	
	& + button {
		margin-top: 10px;
	}

	&:hover,
	&:focus {
		background: #59d9d9;
	}
}

.msg {
	width: 100%;
	text-align: center;
	margin: 0 0 10px 0;
	
	a {
		color: $darkblue;
	}
}
              
            
!

JS

              
                var element = document.getElementById('text');
var page = document.getElementById('page');

// Check I have access to the device orientation event
if (window.DeviceOrientationEvent) {
  window.addEventListener('deviceorientation', doTheTextThing);
}

const results = Splitting();

function doTheTextThing(evt) {
	const value = Math.floor((evt.gamma + 90) / (180 / results[0].chars.length));
	const currentItem = results[0].chars[value];
	
	for (let i = 0; i < results[0].chars.length; i++) {
		results[0].chars[i].style.setProperty('--weight', 200);
		results[0].chars[i].style.setProperty('--transform', 1);
	}
	
	results[0].chars[value].style.setProperty('--weight', 700);
	results[0].chars[value].style.setProperty('--transform', 1.3);
}

// Add a transform scale to it
var button1 = document.getElementById("click-trigger");
var button2 = document.getElementById("ios-trigger");

button1.addEventListener(
	"touchstart",
	function(e) {
		e.preventDefault();
		if (document.body.classList.contains("transform")) {
			document.body.classList.remove("transform");
			button1.textContent = "Add scale transform";
		} else {
			document.body.classList.add("transform");
			button1.textContent = "Reset";
		}
	},
	true
);

button1.addEventListener("click", function(e) {
	if (document.body.classList.contains("transform")) {
		document.body.classList.remove("transform");
		button1.textContent = "Add scale transform";
	} else {
		document.body.classList.add("transform");
		button1.textContent = "Reset";
	}
});

button1.addEventListener("click", function(e) {
	if (document.body.classList.contains("transform")) {
		document.body.classList.remove("transform");
		button1.textContent = "Add scale transform";
	} else {
		document.body.classList.add("transform");
		button1.textContent = "Reset";
	}
});

button2.addEventListener('click', async () => await DeviceMotionEvent.requestPermission());
              
            
!
999px

Console