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

              
                
              
            
!

CSS

              
                html,
body {
	width: 100%;
	height: 100%;
	overflow: hidden;
}

body {
	background: #f63;
}

.flake {
	position: absolute;
	width: 100px;
	height: 100px;
	background-size: cover;
}

.flake1 {
	background-image: url("https://assets.codepen.io/32887/flake1.svg");
}

.flake2 {
	background-image: url("https://assets.codepen.io/32887/flake2.svg");
}

.flake3 {
	background-image: url("https://assets.codepen.io/32887/flake3.svg");
}

.flake4 {
	background-image: url("https://assets.codepen.io/32887/flake4.svg");
}

body {
	background: #ed213a; /* fallback for old browsers */
	background: -webkit-linear-gradient(
		to right,
		#93291e,
		#ed213a
	); /* Chrome 10-25, Safari 5.1-6 */
	background: linear-gradient(
		to right,
		#93291e,
		#ed213a
	); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}

              
            
!

JS

              
                // full video tutorial at: https://www.youtube.com/watch?v=TAVVTRaXm5M

// click anywhere to pause / unpause

let numFlakes = 50;
let width = window.innerWidth;
let height = window.innerHeight;

function createFlake() {
	let flake = document.createElement("div");
	let flakeClass = "flake flake" + gsap.utils.random(1, 4, 1);
	flake.setAttribute("class", flakeClass);
	document.body.appendChild(flake);
	return flake;
}

function animateFlake(flake) {
	let scaleFactor = Power3.easeIn(Math.random());
	// change to easeOut for more larger flakes
	// let scaleFactor = Power3.easeOut(Math.random());
	let scale = gsap.utils.interpolate(0.3, 2, scaleFactor);
	let duration = gsap.utils.interpolate(2, 4, 1 - scaleFactor);
	let opacity = gsap.utils.interpolate(0.5, 1, scaleFactor);
	gsap.set(flake, {
		y: -200,
		x: gsap.utils.random(0, width),
		scale: scale,
		opacity: opacity
	});
	gsap.to(flake, {
		y: height + 200,
		x: "+=200",
		duration: duration,
		delay: "random(0,4)",
		ease: "none",
		rotation: "random(-60, 200)",
		onComplete: animateFlake,
		onCompleteParams: [flake]
	});
}

for (let i = 0; i < numFlakes; i++) {
	let flake = createFlake();
	animateFlake(flake);
}

// document.addEventListener("click", () =>
// 	gsap.globalTimeline.paused(!gsap.globalTimeline.paused())
// );

// full animated snow tutorial: https://www.youtube.com/watch?v=TAVVTRaXm5M

// new JavaScript? Don't worry, my FREE beginner GreenSock course GSAP 3 Express will get you up to speed quickly!
// https://www.creativecodingclub.com/courses/FreeGSAP3Express

// master the GreenSock Animation Platform at:
// https://www.creativecodingclub.com/bundles/creative-coding-club

              
            
!
999px

Console