Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                mixin split(string)
	- var array = string.split('')
	- for (var i = 0; i < array.length; i += 1) 
		span #{array[i]}

div#mode-circle
#blob.blob
.title
	h1
		span
			+split('Dolore')
		span
			+split('Magna')
footer
	button#toggle-mode
		svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none")
			path(id="icon" stroke-linejoin="round" stroke-width="1.5" stroke="currentColor" d="M2.03009 12.42C2.39009 17.57 6.76009 21.76 11.9901 21.99C15.6801 22.15 18.9801 20.43 20.9601 17.72C21.7801 16.61 21.3401 15.87 19.9701 16.12C19.3001 16.24 18.6101 16.29 17.8901 16.26C13.0001 16.06 9.00009 11.97 8.98009 7.13996C8.97009 5.83996 9.24009 4.60996 9.73009 3.48996C10.2701 2.24996 9.62009 1.65996 8.37009 2.18996C4.41009 3.85996 1.70009 7.84996 2.03009 12.42Z")
.noise

              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Montserrat&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Fira+Sans:wght@700&display=swap");

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

:root {
	--padding-container: 16;
	--max-container: 1400px;

	--font-size-title: clamp(4.05rem, 18.78vw + -1.64rem, 11.26rem);

  --bg: hsl(0, 0%, 100%);
  --text-primary: hsl(0, 0%, 10%);

	--blob-color: 33, 139, 10;
	--blob-x: 1;
	--blob-y: 1;
}

html,
body {
	height: 100%;
	font-size: 16px;
}

body {
	background-color: var(--bg);
	width: 100vw;
	height: 100vh;
	font-family: "Montserrat", sans-serif;
	color: var(--text-primary);
	overflow: hidden;
	@supports (height: 100dvh) {
		height: 100dvh;
	}
}

.blob {
	position: absolute;
	transform: translate3d(calc(var(--blob-x) * 1px), calc(var(--blob-y) * 1px), 0);
	width: 50vmin;
	height: 50vmin;
	border-radius: 50%;
	filter: blur(5vmin);
	background: radial-gradient(
		ellipse at center,
		rgba(var(--blob-color), 0.7) 0%,
		rgba(var(--blob-color), 0.65) 100%
	);
	mix-blend-mode: difference;
}
.noise {
	pointer-events: none;
	position: absolute;
	inset: 0;
	width: 100vw;
	height: 100vh;
	background: transparent url("https://assets.codepen.io/108082/Noise.png") 0 0;
	background-size: 320px 320px;
	mix-blend-mode: luminosity;
}

.title {
	display: grid;
	place-items: center;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	padding: 0 calc(var(--padding-container) * 1vmin);
	width: 100%;
	height: 100%;
	mix-blend-mode: difference;
  background: aliceblue;
	@-moz-document url-prefix() {
		mix-blend-mode: unset;
		background: transparent;
	}
	h1 {
		margin: 0 auto;
		width: min(100%, 800px);
		font: bold var(--font-size-title) "Fira Sans", sans-serif;
		text-align: center;
		letter-spacing: 1px;
		text-transform: uppercase;
		& > span {
			display: flex;
			justify-content: space-between;
		}
	}
}

#mode-circle {
	mix-blend-mode: difference;
	pointer-events: none;
	position: fixed;
	inset-block-end: 0;
	inset-inline-end: 0;
	border-radius: 50%;
	background: #fdf4f4;
	width: 20vw;
	height: 20vw;
	transform: scale(0) translate(-50%, -50%);
}

footer {
	mix-blend-mode: difference;
	position: fixed;
	inset-block-end: 32px;
	inset-inline-end: 48px;
	z-index: 2;
	button {
		background: none;
		border: none;
		min-width: 20px;
		font-size: 1.5rem;
		&:hover {
			cursor: pointer;
		}
		svg {
			color: hsl(0, 16%, 84%);
			width: 1em;
			height: 1em;
		}
		#sun, #moon {
			visibility: hidden;
		}
	}
}
              
            
!

JS

              
                gsap.registerPlugin(MorphSVGPlugin);

const toggleModeBtn = document.querySelector('#toggle-mode');
const blob = document.querySelector("#blob");
const modeCircle = document.querySelector("#mode-circle");

const moon = "M2.03009 12.42C2.39009 17.57 6.76009 21.76 11.9901 21.99C15.6801 22.15 18.9801 20.43 20.9601 17.72C21.7801 16.61 21.3401 15.87 19.9701 16.12C19.3001 16.24 18.6101 16.29 17.8901 16.26C13.0001 16.06 9.00009 11.97 8.98009 7.13996C8.97009 5.83996 9.24009 4.60996 9.73009 3.48996C10.2701 2.24996 9.62009 1.65996 8.37009 2.18996C4.41009 3.85996 1.70009 7.84996 2.03009 12.42Z"
const sun = "M19.01 4.99L20 4M4 20L4.99 19.01M12 2.08V1M12 23V21.92M2.08 12H1M22 12H23M4.99 4.99L4 4M20 20L19.01 19.01M18.5 12C18.5 15.5899 15.5899 18.5 12 18.5C8.41015 18.5 5.5 15.5899 5.5 12C5.5 8.41015 8.41015 5.5 12 5.5C15.5899 5.5 18.5 8.41015 18.5 12Z"

const blobRect = blob.getBoundingClientRect();

const blobSizes = {
	width: blobRect.width,
	height: blobRect.height
};

const move = (event: MouseEvent) => {
	let mouseX = event.pageX - blobSizes.width / 2;
	let mouseY = event.pageY - blobSizes.height / 2;

	document.body.style.setProperty(`--blob-x`, mouseX);
	document.body.style.setProperty(`--blob-y`, mouseY);
};

const resize = () => {
	const rect = blob.getBoundingClientRect();
	blobSizes.width = rect.width;
	blobSizes.height = rect.height;
};

let isDark = false
const toggleMode = (event) => {
	event.stopPropagation()
	isDark = !isDark
	let morphSVG = isDark ? sun : moon
	gsap.to('#icon', {
		duration: 1,
		morphSVG: morphSVG,
		ease: "power1.inOut",
	});
	let animateTo = isDark ? {
		duration: 2,
		scale: 20,
		translateX: 0,
		translateY: 0,
	} : {
		duration: 1,
		scale: 0,
		translate: '-50%, -50%',
	}
	gsap.to(modeCircle, {
		...animateTo,
	})
}

window.addEventListener("mousemove", move);
window.addEventListener("resize", resize);
toggleModeBtn.addEventListener('click', toggleMode);

              
            
!
999px

Console