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.

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.

HTML

            
              .badge.p-circle.p-flexcenter
	.badge__inner.p-circle
		.daria
			.daria__specs.daria__specs--left.p-circle.p-flexcenter
				.daria__eyebrow
				.daria__eye.p-circle
			.daria__specs.daria__specs--right.p-circle.p-flexcenter
				.daria__eyebrow
				.daria__eye.p-circle
			.daria__nose
			ul
				- for (var i = 1; i <= 3; i++)
					li(class='daria__hairstyle daria__hair daria__hair--0' + i)
				- for (var i = 1; i <= 4; i++)
					li(class='daria__hairstyle daria__bangs daria__bangs--0' + i)
			.daria__ear.daria__ear--left
			.daria__ear.daria__ear--right
.canvas
            
          
!

CSS

            
              :root { 
	// COLOR CSS VARIABLES 
	--c_01: #f2a3c2; // Pink
	--c_02: #53bfb5; // Mint Green
	--c_03: #1e2022; // Black
	--c_04: #f9cdad; // Skin
	--c_05: #fbffb9; // Yellow
	--c_06: #79412d; // Brown
	--c_07: #0288D1; // Blue
	--c_08: #009688; // Dark Blue/Green

	// SIZE VARIABLES 
	// Resize Daria by editing only the --size variables
	--size: 300px; 
	// Let's resize Daria in other screens
	@media screen and (min-width: 30em) {
		--size: 400px;
	}
	@media screen and (min-width: 85em) {
		--size: 500px;
	}
	@media screen and (min-width: 120em) {
		--size: 600px;
	}
	
	--daria: calc(var(--size) / 2.3);
	--badge_border: calc(var(--size) / 36);
	--specs: calc(var(--size) / 5.5);
	--specs_border: calc(var(--size) / 66);
	--frame_w: calc(var(--specs) / 4);
	--frame_h: var(--specs_border);
	--eye: calc(var(--size) / 50);
	--eyebrow_w: calc(var(--size) / 14);
	--eyebrow_h: calc(var(--specs_border) / 1.6);
	--nose: calc(var(--size) * 0.06);
	--nose_border: calc(var(--size) / 110);
	--bangs_w: calc((var(--size) / 2) * 0.55);
	--bangs_h: calc(var(--bangs_w) / 2);
	--bangs_border: calc(var(--size) / 80);
	--hair: calc(var(--size) / 2.4);
	--hair_border: calc(var(--bangs_border) * 1.2);
	--ear_w: calc(var(--size) / 23);
	--ear_h: calc(var(--size) / 10);
	--ear_border: var(--bangs_border);
}

// MAPS
$z_index: (
	canvas: -10,
	badge_inner: 0,
	specs: 10,
	hair_right: 0,
	hair_top: 10,
	hair_left: 0,
	bangs_right: 20,
	bangs_middle: 30,
	bangs_left_top: 40,
	bangs_left_bottom: 50,
	ear: 60,
);

@function z_index($name) {
  @if map-has-key($z_index, $name) {
    @return map-get($z_index, $name);  
  }
};

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

// LAYOUT
* {
	box-sizing: border-box;
}

body {
	background-color: var(--c_01);
}

:before,
:after {
	content: "";
}

ul {
	list-style-type: none;
}

// PATTERNS
.p {
	&-circle {
		border-radius: 50%;
	}

	&-flexcenter {
		display: flex;
		align-items: center;
		justify-content: center;
	}
}

// ILLUSTRATION
.canvas {
	@include size(100%);
	background-color: var(--c_01);
	position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
	z-index: z_index(canvas);
	transition: background-color 0.2s ease-in-out;
}

.badge {
	@include size(var(--size));
	background-color: var(--c_02);
	border: var(--badge_border) solid var(--c_03);
	margin: 12vh auto;
	
	&:hover {
		background-color: var(--c_05);
		
		+ .canvas {
			background-color: var(--c_02);
		}
		
		.badge__inner {
			background-color: var(--c_01);
		}
		
		.daria__hairstyle {
			--c_06: var(--c_07);
		}
		
		.daria__eye {
			transform: translatex(-50%);
		}
	}

	&__inner {
		@include size(calc(var(--size) / 1.27));
		background-color: var(--c_05);
		border: calc(var(--badge_border) / 1.5) solid var(--c_03);
		overflow: hidden;
		position: relative;
		z-index: z_index(badge_inner); // Fixes Safari's weird border outline
	}
}

.daria {
	@include size(var(--daria));
	background-color: var(--c_04);
	border-radius: 50%/40% 40% 60% 60%;
	margin-left: calc(var(--daria) / -2);
	position: absolute;
	top: calc(var(--daria) / 1.18);
	left: 50%;
	transform: translate3d(0, 0, 0); // Fixes Safari's weird border outline

	&__specs {
		@include size(var(--specs));
		background-color: var(--c_04);
		border: var(--specs_border) solid var(--c_03);
		flex-direction: column;
		position: absolute;
		bottom: calc(var(--daria) / 3.8);
		z-index: z_index(specs);

		&--left {
			margin-left: calc((var(--specs) + (var(--frame_w) / 4)) / -1);
			left: 50%;

			// Specs Frame
			&:before {
				@include size(var(--frame_w), var(--frame_h));
				background-color: var(--c_03);
				margin-top: calc(var(--frame_h) / -2);
				position: absolute;
				top: 50%;
				right: calc(var(--frame_w) * -1);
			}
		}

		&--right {
			margin-left: calc(var(--frame_w) / 4);
			left: 50%;
		}
	}
	
	&__eyebrow {
		@include size(var(--eyebrow_w), var(--eyebrow_h));
		background-color: var(--c_03);
		margin-top: var(--eye);
	}

	&__eye {
		@include size(var(--eye));
		background-color: var(--c_03);
		margin-top: calc(var(--eyebrow_h) * -1);
		transition: transform 0.1s linear;
	}

	&__nose {
		@include size(var(--nose), calc(var(--nose) / 1.2));
		border-color: transparent transparent var(--c_03) transparent;
		border-width: var(--nose_border);
		border-style: solid;
		border-radius: 50%/0 0 40% 40%;
		margin-left: calc(var(--nose) / -2);
		position: absolute;
		bottom: calc(var(--daria) / 6);
		left: 50%;
	}
	
	&__hairstyle {
		background-color: var(--c_06);
		backface-visibility: hidden; // Fixes jagged edges in borders
		border-style: solid;
		border-color: var(--c_03);
		position: absolute;
		transform-style: preserve-3d; // Fixes Firefox Bug
		transform: translate3d(0, 0, 0); // Fixes Safari's weird border outline
	}
	
	&__hair {
		border-width: var(--hair_border);

		// Hair - Right
		&--01 {
			@include size(var(--hair), calc(var(--hair) * 0.42));
			border-radius: 100% 50% 0 50%;
			top: calc(var(--daria) / 5.5);
			right: calc(var(--daria) / -1.95);
			transform: rotate(83deg);
			z-index: z_index(hair_right);
		}
		
		// Hair - Top
		&--02 {
			@include size(calc(var(--hair) * 1.1), calc(var(--hair) / 2));
			border-radius: var(--hair) var(--hair) 0 0;
			border-bottom: 0;
			top: calc(var(--daria) / -4.3);
			right: calc(var(--daria) / 17);
			transform: rotate(-5deg);
			z-index: z_index(hair_top);
			
			&:before {
				@include size(calc(var(--bangs_border) * 4), var(--specs));
				@extend .p-circle;
				background-color: var(--c_06);
				position: absolute;
				top: calc(var(--bangs_border) * 3.5);
				left: calc(var(--bangs_border) / -2.9);
				transform: rotate(35deg);
			}
			
			&:after {
				@include size(calc(var(--bangs_border) * 4.5), calc(var(--specs) / 1.5));
				background-color: var(--c_06);
				border-radius: 0;
				position: absolute;
				top: calc(var(--daria) / 4.4);
				right: calc(var(--bangs_border) * -3);
				transform: rotate(-30deg);
			}
		}
		
		// Hair - Left
		&--03 {
			@include size(calc(var(--hair) * 1.1), calc(var(--hair) / 2.5));
			border-radius: var(--hair) 150% 0 0;
			border-bottom: 0;
			bottom: calc(var(--daria) / 2.5);
			left: calc(var(--daria) / -1.8);
			transform: rotate(-75deg);
			z-index: z_index(hair_left);
		}
	}
	
	&__bangs {
		border-width: var(--bangs_border);
		border-bottom-left-radius: var(--bangs_w);
		border-bottom-right-radius: var(--bangs_w);
		border-top: 0;
		border-left: 0;

		// Bangs - Right
		&--01 {
			@include size(var(--bangs_w), var(--bangs_h));
			top: calc(var(--daria) / 25);
			right: calc(var(--daria) / 7.2);
			z-index: z_index(bangs_right);
			transform: rotate(25deg);
			
			&:after {
				@include size(calc(var(--bangs_border) * 1.5), calc(var(--specs) / 2));
				background-color: var(--c_06);
				position: absolute;
				top: calc(var(--bangs_border) * -0.1);
				left: calc(var(--bangs_border) * -0.2);
				transform: rotate(-20deg);
			}
		}
		
		// Bangs - Middle
		&--02 {
			@include size(calc(var(--bangs_w) / 1.2), var(--bangs_h));
			top: calc(var(--daria) / 16);
			left: calc(var(--bangs_border) * 2);
			z-index: z_index(bangs_middle);
			transform: rotate(20deg);
			
			&:after {
				@include size(calc(var(--bangs_border) * 1.5), calc(var(--specs) / 3));
				@extend .p-circle;
				background-color: var(--c_06);
				position: absolute;
				top: calc(var(--bangs_border) * 1.1);
				left: 0;
				transform: rotate(-20deg);
			}
		}
		
		// Bangs - Left Top
		&--03 {
			@include size(calc(var(--bangs_w) / 1.7), calc(var(--bangs_h) / 1));
			top: calc(var(--daria) / 11);
			left: calc(var(--daria) * -0.062);
			transform: rotate(22deg);
			z-index: z_index(bangs_left_top);
			
			&:after {
				@include size(calc(var(--bangs_border) * 3), calc(var(--specs) / 2));
				@extend .p-circle;
				background-color: var(--c_06);
				position: absolute;
				top: calc(var(--bangs_border) * 4.5);
				left: calc(var(--bangs_border) / -3);
				transform: rotate(-20deg);
			}
		}
		
		// Bangs - Left Bottom 
		&--04 {
			@include size(calc(var(--bangs_w) / 2.5), calc(var(--bangs_h) * 1.2));
			top: calc(var(--daria) / 5);
			left: calc(var(--daria) * -0.105);
			z-index: z_index(bangs_left_bottom);
			transform: rotate(52deg);	
			
			&:after {
				@include size(calc(var(--bangs_w) / 3.2), calc(var(--specs) / 2));
				background-color: var(--c_06);
				position: absolute;
				top: calc(var(--bangs_border) * 6.8);
				left: calc(var(--bangs_border) * 0.7);
				transform: rotate(-40deg);
			}
		}
	}

	&__ear {
		@include size(var(--ear_w), var(--ear_h));
		background-color: var(--c_04);
		border: var(--ear_border) solid var(--c_03);
		border-radius: 43%;
		position: absolute;
		bottom: calc(var(--daria) / 7);
		z-index: z_index(ear);
		
		&--left {
			left: calc(var(--daria) / 20);
			transform: rotate(-20deg);
		}
		
		&--right {
			right: calc(var(--daria) / 20);
			transform: rotate(15deg);		
		}
	}
}
            
          
!

JS

            
              /* 
 * PURE CSS DARIA MORGENDORFFER
 * Hover daria for that emo look and blue hair.
 * Responsive daria via 4 breakpoints.
 * Resizable daria with just 1 CSS edit.
 *
 * Inspired by the legendary MTV's cartoon character — Daria.
 *
 * Don't know who daria is? Say what?
 * https://www.youtube.com/watch?v=2TAGtY1SsfU
 *
 * By ilithya | 2019
 */
            
          
!
999px

Console