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 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

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

              
                <div class="wrapper">
  <div class="text">
    		<div class="text__tag text__tag--spooky">Spoooky...</div>
    		<div class="text__tag text__tag--scary">Scary!</div>
    	</div>
        <div class="ghost">
        	<div class="ghost__wrapper ghost__wrapper--walking">
        	<div class="ghost__wrapper ghost__wrapper--hover">
        	<div class="ghost__wrapper ghost__wrapper--flip">
	            <div class="ghost__body">
	                <div class="ghost__bodypart">
	                    <div class="ghost__bodypart">
	                        <div class="ghost__bodypart">
	                            <div class="ghost__bodypart">
	                                <div class="ghost__bodypart">
	                                    <div class="ghost__bodypart">
	                                        <div class="ghost__bodypart">
	                                            <div class="ghost__bodypart">
	                                                <div class="ghost__bodypart">
	                                                    <div class="ghost__bodypart">
	                                                        <div class="ghost__bodypart">
	                                                            <div class="ghost__bodypart">
	                                                                <div class="ghost__bodypart">
	                                                                    <div class="ghost__bodypart">
	                                                                        <div class="ghost__head">
	                                                                        	<div class="ghost__wrapper ghost__wrapper--faceswing">
	                                                                            <div class="ghost__face">
	                                                                                <div class="ghost__mouth"></div>
	                                                                            </div>
	                                                                            </div>
	                                                                        </div>
	                                                                    </div>
	                                                                </div>
	                                                            </div>
	                                                        </div>
	                                                    </div>
	                                                    <div class="ghost__arms">
	                                                        <div class="ghost__arm">
	                                                            <div class="ghost__armpart">
	                                                                <div class="ghost__armpart">
	                                                                    <div class="ghost__armpart">
	                                                                        <div class="ghost__armpart">
	                                                                            <div class="ghost__armpart ghost__armpart--nodeup">
	                                                                                <div class="ghost__armpart">
	                                                                                    <div class="ghost__armpart">
	                                                                                        <div class="ghost__armpart">
	                                                                                            <div class="ghost__armpart">
	                                                                                                <div class="ghost__armpart ghost__armpart--nodedown">
	                                                                                                    <div class="ghost__armpart">
	                                                                                                        <div class="ghost__armpart">
	                                                                                                            <div class="ghost__armpart">
	                                                                                                                <div class="ghost__armpart">
	                                                                                                                </div>
	                                                                                                            </div>
	                                                                                                        </div>
	                                                                                                    </div>
	                                                                                                </div>
	                                                                                            </div>
	                                                                                        </div>
	                                                                                    </div>
	                                                                                </div>
	                                                                            </div>
	                                                                        </div>
	                                                                    </div>
	                                                                </div>
	                                                            </div>
	                                                        </div>
	                                                        <div class="ghost__arm ghost__arm--other">
	                                                            <div class="ghost__armpart">
	                                                                <div class="ghost__armpart">
	                                                                    <div class="ghost__armpart">
	                                                                        <div class="ghost__armpart">
	                                                                            <div class="ghost__armpart ghost__armpart--nodeup">
	                                                                                <div class="ghost__armpart">
	                                                                                    <div class="ghost__armpart">
	                                                                                        <div class="ghost__armpart">
	                                                                                            <div class="ghost__armpart">
	                                                                                                <div class="ghost__armpart ghost__armpart--nodedown">
	                                                                                                    <div class="ghost__armpart">
	                                                                                                        <div class="ghost__armpart">
	                                                                                                            <div class="ghost__armpart">
	                                                                                                                <div class="ghost__armpart">
	                                                                                                                </div>
	                                                                                                            </div>
	                                                                                                        </div>
	                                                                                                    </div>
	                                                                                                </div>
	                                                                                            </div>
	                                                                                        </div>
	                                                                                    </div>
	                                                                                </div>
	                                                                            </div>
	                                                                        </div>
	                                                                    </div>
	                                                                </div>
	                                                            </div>
	                                                        </div>
	                                                    </div>
	                                                </div>
	                                            </div>
	                                        </div>
	                                    </div>
	                                </div>
	                            </div>
	                        </div>
	                    </div>
	                </div>
	            </div>
	            <div class="ghost__maybefeet">
	                <div class="ghost__feet"></div>
	                <div class="ghost__feet"></div>
	                <div class="ghost__feet"></div>
	                <div class="ghost__feet"></div>
	                <div class="ghost__feet"></div>
	                <div class="ghost__feet"></div>
	            </div>
	        </div>
	        </div>
	        </div>
        </div>
    </div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Indie+Flower');

html {
	font-size: 11px;
}
body {
	background-color: #000;
	margin: 0;
	padding: 0;
	height: 100vh;
	width: 100vw;
	overflow: hidden;
	perspective: 1000px;
}

%eyesymbol {
	padding: 1.6rem .8rem;
	position: absolute;
	top: 50%;
	left: 50%;
	background-color: #000;
	border-radius: 50%;
	transform: translateX(-50%);
}

@keyframes hover {
	from {
		transform: translateY(0);
	}
	to {
		transform: translateY(-12px);
	}
}
@keyframes walk-around {
	0% {
		transform: translateX(-20vw);
	}
	40% {
		transform: translateX(20vw);
	}
	50% {
		transform: translateX(20vw);
	}
	90% {
		transform: translateX(-20vw);
	}
	100% {
		transform: translateX(-20vw);
	}
}
@keyframes flip {
	2%, 30%, 100% {
		transform: scaleX(1);
	}
	55%, 75% {
		transform: scaleX(-1);
	}
}
@keyframes swing {
	0% {
		transform: rotateZ(-2deg);
	}
	50% {
		transform: rotateZ(2deg);
	}
	100% {
		transform: rotateZ(-2deg);
	}
}
@keyframes faceswing {
	0% {
		transform: rotateZ(15deg) translateX(20px);
	}
	50% {
		transform: rotateZ(-30deg) translateX(20px);
	}
	100% {
		transform: rotateZ(15deg) translateX(20px);
	}
}
@keyframes faceblink {
	from {
		transform: scale()
	}
}
@keyframes shake-arm-left {
	0% {
		transform: rotateZ(30deg);
	}
	15% {
		transform: rotateZ(15deg);
	}
	28% {
		transform: rotateZ(28deg);
	}
	44% {
		transform: rotateZ(10deg);
	}
	66% {
		transform: rotateZ(40deg);
	}
	85% {
		transform: rotateZ(25deg);
	}
}
@keyframes movetext {
	0% {
		opacity: 0;
		left: 100%;
	}
	20%, 60% {
		opacity: 1;
	}
	80% {
		opacity: 0;
	}
	100% {
		opacity: 0;
		left: 0%;
		transform: translate(0%, -50%) skewX(-30deg);
	}
}

.text {
	font-family: 'Indie Flower', cursive;
	&__tag {
		position: absolute;
		z-index: -100;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		color: #fff;
		font-size: 10rem;
		animation: movetext 3s ease 0s infinite;
		&--spooky {
			top: 20%;
		}
		&--scary {
			top: 80%;
		}
	}
}
// Body
.ghost {
	max-width: 11rem;
	width: 100%;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	&__wrapper {
		&--hover {
			animation: hover .33s ease-in-out 0s infinite alternate;
		}
		&--walking {
			animation: walk-around 6s linear 0s infinite;
		}
		&--flip {
			animation: flip 6s cubic-bezier(0.66, -0.37, 0.34, 1.27) 0s infinite;
		}
		&--faceswing {
		    position: absolute;
		    width: 100%;
		    height: 100%;
		    top: 0;
		    left: 0;
		    transform-origin: 50% 100%;
			animation: faceswing 1.8s ease 0s infinite;
		}
	}
	&__body {
		width: 100%;
		position: relative;
		min-height: 28rem;
	}
	&__bodypart {
		.ghost__body > & {
			top: auto;
			bottom: 0;
			position: absolute;
			transform: none !important;
			animation: none !important;
		}
		background-color: #fff;
		height: 0;
		padding: 1rem 0;
		width: 100%;
		top: -2.5rem;
		left: 0;
		position: relative;
		animation: swing 1.8s ease 0s infinite;

	}
	&__head {
		width: 100%;
		background-color: #fff;
		font-size: 2rem;
		padding: 5.5rem 0 0;
		position: absolute;
		top: 1px;
		left: 0;
		border-radius: 60px 60px 0 0;
		transform: translateY(-100%);
	}
	&__face {
		&:before, &:after {
			content: "";
			@extend %eyesymbol;
			padding: 1.5rem .75rem;
		}
		&:before {
			left: 35%;
			
		}
		&:after {
			left: 65%;
		}
	}
	&__mouth {
		@extend %eyesymbol;
		top: 100%;
		transform: translateX(-50%) translateY(5px);
		left: 50%;
	}
}

// Arms
.ghost {
	&__arms {
		position: absolute;
		top: -2rem;
		padding: 10px;
		width: 100%;
		left: 0;
	}
	&__arm {
		top: -1rem;
		left: 1rem;
		position: absolute;
		width: 2rem;
		height: 100%;
		animation: shake-arm-left 5s ease 0s infinite alternate;
		&--other {
			left: auto;
			right: 3rem;
			z-index: -1;
			top: -3rem;
			transform: rotateZ(29deg) scale(.7);
			animation: none;
		}
	}
	&__armpart {
		.ghost__arm > & {
			transform: rotateZ(-45deg);
		}
		position: absolute;
		top: -2px;
		left: calc(100% + 1px);
		width: .7rem;
		height: 100%;
		border-top: 2px solid black;
		border-bottom: 2px solid black;
		background-color: #fff;
		transform: rotateZ(15deg);
		.ghost__armpart--nodeup & {
			transform: rotateZ(-15deg);
		}
		.ghost__armpart--nodedown & {
			transform: rotateZ(15deg);
		}
	}
}

// Feet?
.ghost {
	&__maybefeet {
		font-size: 0;
	}
	&__feet {
		border-top: 12px solid #fff;
		border-left: 1.1rem solid transparent;
		border-right: 1.1rem solid transparent;
		display: inline-block;
		&:first-child {
			border-left: none;
		}
		&:last-child {
			border-right: none;
		}
	}
}

              
            
!

JS

              
                // The concept for the animation is basically this:
/*
  Curves in 3d drawings are made with lines connecting with each other
  So if I can simulate this on HTML and CSS, and I can bend objects using multiple elements aligned with each other
  That's just how the ghost is bending itself. A handful of parenting divs, rotating to the same direction
  
  Also, in order to control multiple animations, the best solution is to apply multiple controllers to it. A bigger DOM element hierarchy provides multiple possibilities for the "transform" rule, since you can apply a different transformation to each controller. */
              
            
!
999px

Console