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

              
                .new-year-party
	.balloon
	.balloon.balloon--happy
		h1.balloon__nr 2
	.balloon.balloon--new
		h1.balloon__nr 0
	.balloon.balloon--happy
		h1.balloon__nr 2
	.balloon.balloon--new
		h1.balloon__nr 0

              
            
!

CSS

              
                :root {
	// COLOR CSS VARIABLES
	--c01: #b29600; // Gold
	--c02: #2c2828; // Black
	--c03: #fffdf6; // White
	--c04: #d2b793; // Dark Sand
	--color_bg: #dfd3c3; // Sand
	--color_balloon: var(--c02); 
	
	// SIZE CSS VARIABLES
	// Resize balloons by only editing the --balloon variable
	--balloon: 80px; 
	// Let's resize balloons in other screens
	@media screen and (min-width: 52em) {
		--balloon: 140px;
	}
	@media screen and (min-width: 88em) {
		--balloon: 200px;
	}
	
	--balloon_half: calc(var(--balloon) / 2);
	--knot: calc(var(--balloon) / 10);
	--border: 10px;
}

// MIXINS
@mixin size($w, $h: $w) {
	width: $w;
	height: $h;
}

@mixin animation($name, $time) {
	animation: 
		fly_away $time forwards,
		$name 4s $time 400 ease-in-out alternate;
}

// PLACEHOLDERS
%transition {
	transition: all 0.2s ease-in-out;
}

// LAYOUT
body {
	background-color: var(--color_bg);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23d2b793' fill-opacity='0.4'%3E%3Cpath d='M0 38.59l2.83-2.83 1.41 1.41L1.41 40H0v-1.41zM0 1.4l2.83 2.83 1.41-1.41L1.41 0H0v1.41zM38.59 40l-2.83-2.83 1.41-1.41L40 38.59V40h-1.41zM40 1.41l-2.83 2.83-1.41-1.41L38.59 0H40v1.41zM20 18.6l2.83-2.83 1.41 1.41L21.41 20l2.83 2.83-1.41 1.41L20 21.41l-2.83 2.83-1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L20 18.59z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
	margin: 0;
}

.new-year-party {
	@include size(calc(100vw - 20px), calc(100vh - 20px));
	box-sizing: border-box;
	display: flex; // Grid Fallback
	display: grid;
	grid-auto-flow: column;
	justify-content: center;
	margin: var(--border);
	overflow: hidden;
	padding-top: calc(var(--border) * 2);
}

// ILLUSTRATION
.balloon {
	@include size(var(--balloon));
	@extend %transition;
	background-image: url('https://image.freepik.com/free-photo/glitter-background-for-new-year_23-2148002042.jpg');
	background-position: 60% 50%;
	background-blend-mode: screen;
	background-color: var(--color_balloon);
	border-radius: 0 var(--balloon_half) var(--balloon_half);
	border: 1px solid transparent; // Fixes jagged edges in Safari
	position: relative;
	transform: rotate(-135deg) translate(-100vh, -100vh);
	transform-style: preserve-3d; // Fixes Firefox Bug
	
	&:not(:last-child) {
		margin-right: calc(var(--balloon_half) / 4);
	}

	// Balloon's Knot
	&:before {
		@include size(0);
		@extend %transition;
		content: "";
		border-style: solid;
		border-width: calc(var(--knot) * 1.5) var(--knot) 0 var(--knot);
		border-color: var(--color_balloon) transparent transparent transparent;
		position: absolute;
		top: calc(var(--knot) / -1);
		left: calc(var(--knot) * -1.3);
		transform: rotate(-45deg);
	}

	// Balloon's String
	&:after {
		@include size(1px, calc(var(--balloon) * 2.5));
		@extend %transition;
		content: "";
		background-color: var(--c02);
		position: absolute;
		bottom: calc(var(--balloon) / 1.54);
		left: calc(var(--balloon) / -1.1);
		transform: rotate(135deg);
		z-index: -1;
	}

	// Balloon Colors
	&--happy {
		--color_balloon: var(--c01);
	}

	&--new {
		--color_balloon: var(--c03);
	}
	
	// Balloon's Number
	&__nr {
		display: inline-block;
		font-family: 'Alfa Slab One', cursive;
		font-size: calc(var(--balloon) * 0.19);
		transform: rotate(135deg) translateY(-100%);
		opacity: 0.75;
	}
	
	// #3
	&:nth-child(1) {
		@include animation(float_left_top, 3s);
	}
	
	// Balloon's Animation
	// #1
	&:nth-child(2) {
		@include animation(float_right_bottom, 1s);
	}
	
	// #5
	&:nth-child(3) {
		@include animation(float_left_top, 5s);
	}
	
	// #4
	&:nth-child(4) {
		@include animation(float_left_top, 4s);
	}
	
	// #2
	&:nth-child(5) {
		@include animation(float_right_bottom, 2s);
	}
}

// ANIMATIONS
@keyframes fly_away {
	100% {
		transform: rotate(-135deg) translate(0, 0);
	}
}

@keyframes float_right_bottom {
	0%, 100% {
		transform: rotate(-135deg) translate(0, 0);
	}
	50% {
		transform: rotate(-135deg) translate(calc(var(--knot) * -1), 0);
	}
}

@keyframes float_left_top {
	0%, 100% {
		transform: rotate(-135deg) translate(0, 0);
	}
	50% {
		transform: rotate(-135deg) translate(0, var(--knot));
	}
}

@keyframes float_left_bottom {
	0%, 100% {
		transform: rotate(-135deg) translate(0, 0);
	}
	50% {
		transform: rotate(-135deg) translate(0, calc(var(--knot) * -1));
	}
}

              
            
!

JS

              
                /* 
 * PURE CSS NEW YEARS BALLOONS 
 * Responsive balloons with 3 breakpoints.
 * Resizable balloons with just 1 CSS edit.
 *
 * Happy new year!
 * By ilithya | 2019
 *
 * Glitter background image created by Freepik
 * https://image.freepik.com/free-photo/glitter-background-for-new-year_23-2148002042.jpg
 */
//Forked by https://codepen.io/ilithya/pen/ZVOgro
              
            
!
999px

Console