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

              
                .layout
	.forest
		- for (var i = 0; i < 3; i++)
			.forest__inner
				.forest--small
					.forest__wrapper
						- for (var x = 0; x < 7; x++)
							.forest__tree
				.forest--big
					.forest__wrapper
						- for (var x = 0; x < 7; x++)
							.forest__tree
			
	.car
		.car__backWall
		.car__windowFrontBlick
		.car__window--frontal
			.window-frontal__angle
		.car__chairs
			.car__chair
				.car__chairHead
			.car__chair
				.car__chairHead
			.car__belt
			
		.granddad
			.granddad__body
			.granddad__hand
			.granddad__neck
			.grandad__header
				.granddad__head
					.grandad__bread
						.grandad__mouth
					.granddad__eyes
					.granddad__nose
					.granddad__ear.granddad__ear--left
					.granddad__ear.granddad__ear--right
					.granddad__hat
		
		.car__steeringWheel
		.car__window--glass
			.car__reflection-cars
				each color in ['red', 'yellow', 'purple', 'green']
					div(class='car__reflection-car car__reflection-car--'+color)
					
		.car__window
			.window__angle.window__angle--top-right
			.window__angle.window__angle--bottom-right
			.window__angle.window__angle--bottom-left
		.car__mirror
			.car__turnSignal

              
            
!

CSS

              
                @mixin size($x, $y: $x) {
	width: $x;
	height: $y;
}

@mixin stretch {
	position: absolute;
	bottom: 0;
	right: 0;
	top: 0;
	left: 0;
}

@mixin helper-position {
	display: flex;
	justify-content: flex-end;
	position: absolute;
	left: 110px;
	right: 0;
	bottom: 0;
	max-width: var(--limited-width);
}

@mixin helper-flex-end {
	display: flex;
	align-items: flex-end;
}

@mixin helper-pseudo-content-block {
	display: block;
	content: '';
}

:root {
	--forest: rgba(150, 183, 190, 1);
	--sky: rgba(170, 216, 241,1);
	--glass: rgba(184, 218, 241, .4);
	--car: rgba(255, 247, 232, 1);
	--car-window: rgba(246, 236, 215, 1);
	--car-shadow: rgba(230, 221, 203, 1);
	--car-wall: rgba(220, 207, 179, 1);
	--armchairs: rgba(186, 112, 87, 1);
	--armchairs-dark: rgba(174, 101, 77, 1);
	--black: rgba(71, 71, 76, 1);
	--skin-face: rgba(255, 172, 126, 1);
	--skin: rgba(255, 150, 113, 1);
	--hat: rgba(166, 150, 142, 1);
	--mouth: rgba(195, 93, 100, 1);
	--turn-signal-orange: rgba(255, 134, 65, 1);
	--turn-signal-yellow: rgba(255, 199, 65, 1);
	--tongue: rgba(254, 105, 89, 1);
	--white: rgba(255, 255, 255, 1);
	--cloth: rgba(178, 163, 158, 1);
	
	--width-window: 74px;
	--limited-width: 800px;
	
	--animation-name-common-move: moveHeadPieces;
	--duration-move-head: 2.5s;
	--function-easing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
} 

body {
	background-color: #232323;
	color: var(--white);
	.layout {
		position: relative;
		@include size(100vw, 100vh);
		min-width: var(--limited-width);
		min-height: 600px;
		margin: 0 auto;
		overflow: hidden;
		background-color: var(--sky);
	}
}

.forest {
	position: absolute;
	bottom: 0;
	@include helper-flex-end;
	.forest__inner {
		animation: moveForest 5s linear infinite forwards;
		&, .forest__wrapper {
			@include helper-flex-end;
		}
		> div {
			&:after {
				@include helper-pseudo-content-block;
				width: calc(100% + 6px);
				margin-left: -13px;
				background-color: var(--forest);
			}
			&.forest--small {
				&:after {height: 40vh;}
			}
			&.forest--big {
				&:after {height: 33vh;}
			}
		}
	}
	
	.forest__tree {
		background-color: var(--forest);
		border-radius: 60px 60px 0 0;
		width: 130px;
		margin-left: -20px;
		margin-bottom: -15px;
		@for $i from 1 through 4 {
			&:nth-child(#{$i}) {
				height: (8*$i)+vh;
				transform: rotate(-10deg);
			}
		}
		&:nth-child(4) {
			transform: rotate(0);
		}
		@for $i from 5 through 7 {
			&:nth-child(#{$i}) {
				height: ((8 - $i) * 8)+vh;
				transform: rotate(10deg);
			}
		}
	}
}

.car {
	position: absolute;
	left: -10px;
	@include size(110vw, 102vh);
	min-width: var(--limited-width);
	min-height: 600px;
	animation: jumpCar .1s ease infinite alternate,
		moveCar 1.5s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite alternate;
	z-index: 2;
	.car__backWall {
		position: absolute;
		top: -60px;
		left: 400px;
		@include size(100%, 100%);
		border: 150px solid var(--car-wall);		
		border-right-color: transparent;
		border-bottom-color: transparent;
		border-radius: 200px 200px 0 0;
	}
	.car__windowFrontBlick {
		position: absolute;
		top: 300px;
		left: -235px;
		@include size(100px, 140px);
		transform: skew(40deg);
		background-color: rgba(#fff, .6);
		animation: moveFrontBlick 4s cubic-bezier(0.77, 0, 0.175, 1) infinite;
		z-index: -2;
	}
	.car__window {
		@include stretch;
		max-width: var(--limited-width);
		border: var(--width-window) solid var(--car-window);
		border-radius: 600px 150px 150px 150px;
		box-shadow: inset 0 0 0 20px var(--car-shadow);
		z-index: 3;
		.window__angle {
			background-color: var(--car-window);
			position: absolute;
			@include size(130px);
			@media (max-width: 567px) {
				width: 150px;
			}
			&--top-right {
				top: calc(var(--width-window) * -1);
				right: calc(var(--width-window) * -1);
				border-radius: 0 0 0 150px;
			}
			&--bottom-right {
				bottom: calc(var(--width-window) * -1);
				right: calc(var(--width-window) * -1);
				border-radius: 150px 0 0 0;
			}
			&--bottom-left {
				bottom: calc(var(--width-window) * -1);
				left: calc(var(--width-window) * -1);
				border-radius: 0 150px 0 0;
			}
		}
		@media (min-width: 920px) {
			&:after {
				@include helper-pseudo-content-block;
				position: fixed;
				top: 0;
				right: 0;
				left: 920px;
				height: 100%;
				background-color: var(--car-window);
			}
		}

		&--frontal {
			position: relative;
			@include size(50%, 100%);
			border: calc(var(--width-window) * 1.5 + 24px) solid var(--car);
			box-shadow: inset 0 0 0 20px var(--car-shadow);
			border-radius: 0 225px 0 0;
			transform: skew(-30deg) translate(-100%, -60px);
			.window-frontal__angle {
				position: absolute;
				top: calc(var(--width-window) * -1.5);
				left: 0;
				right: calc(var(--width-window) * -6);
				background-color: var(--car);
				height: calc(var(--width-window) * 1.5);		
			}
			&:after {
				@include helper-pseudo-content-block;
				position: absolute;
				right: -200px;
				top: -80px;
				background-color: var(--car);
				@include size(150px, 200px);
				border-radius: 0 0 150px 0;
			}
		}
		
		&--glass {
			position: absolute;
			right: calc(var(--width-window) - 40px);
			bottom: var(--width-window);
			overflow: hidden;
			left: 220px;
			height: 170px;
			background-color: var(--glass);
			border-radius: 300px 60px 0 0;
			transform: skew(-40deg);
			z-index: 3;
			&:before {
				@include helper-pseudo-content-block;
				position: absolute;
				@include size(80px, inherit);
				transform: skew(60deg);
				background-color: rgba(#fff, .5);
				animation: moveBlick 4s cubic-bezier(0.77, 0, 0.175, 1) infinite;
			}
		}
	}
	.car__reflection-cars {
		display: flex;
		position: absolute;
		bottom: -20px;
		left: 0;
		animation: moveCars 2s linear infinite forwards;
		.car__reflection-car {
			margin-left: 550px;
			@include size(700px, 90px);
			border-radius: 90px 90px 0 0;
			transform: skew(40deg);
			&:after, &:before {
				@include helper-pseudo-content-block;
				position: absolute;
				top: -170px;
				@include size(136px, 80px);
				border: 90px solid transparent;
				border-bottom: none;
				
			}
			&:before {
				left: 80px;
				border-right-width: 44px;
				border-radius: 200px 0 0 0;
			}
			&:after {
				right: 80px;
				border-left-width: 45px;
				border-radius: 0 200px 0 0;
			}
			@each $color in red, yellow, purple, green {
				&--#{$color} {
					background-color: rgba($color, .3);
					&:after, &:before {
						border-color: rgba($color, .3)
					}
				}
			}
		}
	}
	.car__chairs {
		@include helper-position;
		.car__chair {
			margin: 0 10px;
			@include size(220px, 340px);
			background-color: var(--armchairs);
			border-radius: 50px 50px 0 0;
			&:before {
				@include helper-pseudo-content-block;
				@include size(100px, inherit);
				margin-left: 120px;
				background-color: var(--armchairs-dark);
				border-radius: inherit;
			}
		}
		.car__chairHead {
			position: absolute;
			bottom: 340px;
			@include size(220px, 150px);
			background-color: var(--armchairs);
			border-radius: 50px;
			&:before {
				@include helper-pseudo-content-block;
				@include size(100px, inherit);
				margin-left: 120px;
				background-color: var(--armchairs-dark);
				border-radius: inherit;
			}
		}
		.car__belt {
			position: absolute;
			right: 180px;
			bottom: 0;
			@include size(70px, 500px);
			background-color: var(--black);
			transform: skew(-40deg);
			z-index: 3;
		}
	}
	
	.car__steeringWheel {
		position: absolute;
		left: 30px;
		bottom: -40px;
		@include size(200px, 200px);
		border: 30px solid var(--black);
		border-radius: 50%;
	}
	.car__mirror {
		position: absolute;
		bottom: 20px;
		left: 10px;
		z-index: 3;
		&:after, &:before {
			@include helper-pseudo-content-block;
			position: absolute;
			left: 0;
			background-color: var(--car);			
		}
		&:before {
			bottom: 40px;
			@include size(90px, 140px);
			border-radius: 0 0 50px 50px;
			box-shadow: 0px 2px 0 1px rgba(#000, .03);
		}
		&:after {
			bottom: 120px;
			@include size(200px, 130px);
			border-radius: 50px;
		}
		.car__turnSignal {
			position: absolute;
			bottom: 165px;
			left: 130px;
			@include size(70px, 40px);
			border-radius: 30px 0 0 30px;
			background-color: var(--turn-signal-orange);
			animation: blinkTurnSignal 1s steps(1) infinite;
			z-index: 1;
			&:before {
				content: '';
				display: block;
				position: absolute;
				top: 10px;
				left: 10px;
				@include size(60px, 20px);
				border-radius: inherit;
				background-color: var(--turn-signal-yellow);
			}
		}
	}
}

.granddad {
	@include helper-position;
	.granddad__body {
		margin-right: 110px;
		@include size(320px, 330px);
		border-radius: 150px 150px 0 0;
		background-color: var(--cloth);
	}
	.granddad__hand {
		position: absolute;
		top: 140px;
		left: 110px;
		@include size(90px);
		background-color: var(--skin-face);
		border-radius: 50%;
		animation: moveHand 1s cubic-bezier(0.55, 0.085, 0.68, 0.53) infinite alternate;
		z-index: 3;
	}
	.granddad__neck {
		position: absolute;
		right: 310px;
		top: -50px;
		@include size(60px, 120px);
		border-radius: 30px;
		transform: rotate(-40deg);
		background-color: var(--skin);
		animation: jumpNeck .7s ease infinite alternate;
	}
	.grandad__header {
		position: relative;
		animation: jumpHead .7s ease infinite alternate,
			moveHead var(--duration-move-head) var(--function-easing) infinite;
		.granddad__head {
			position: absolute;
			right: 310px;
			top: -190px;
			@include size(180px, 240px);
			&:before {
				@include helper-pseudo-content-block;
				position: absolute;
				@include size(100%);
				background-color: var(--skin-face);
				border-radius: 80px;
				z-index: 2;
			}
		}
		.grandad__bread {
			position: absolute;
			bottom: -60px;
			left: -10px;
			@include size(200px, 160px);
			border-radius: 80px;
			background-color: var(--white);
			animation: var(--animation-name-common-move) var(--duration-move-head) var(--function-easing) infinite;
			z-index: 3;
			&:before {
				@include helper-pseudo-content-block;
				position: absolute;
				top: -10px;
				left: 55px;
				@include size(80px, 30px);
				border-radius: 20px;
				background-color: var(--white);
			}
			&:after {
				@include helper-pseudo-content-block;
				position: absolute;
				top: 38px;
				left: 60px;
				@include size(40px, 0px);
				border-radius: 50%;
				border: 15px solid var(--white);
			}
			.grandad__mouth {
				position: absolute;
				top: 20px;
				left: 70px;
				@include size(20px, 0px);
				border-radius: 50%;
				border: 15px solid var(--mouth);
				animation: scaleMouth 1.5s ease infinite alternate;
				&:after {
					@include helper-pseudo-content-block;
					position: absolute;
					top: -5px;
					@include size(20px);
					border-radius: 50%;
					background-color: var(--tongue);
					animation: moveTongue var(--duration-move-head) var(--function-easing) infinite;
				}
			}
		}
		.granddad__eyes {
			display: flex;
			justify-content: space-between;
			width: 80px;
			position: absolute;
			top: 100px;
			left: 47px;
			animation: var(--animation-name-common-move) var(--duration-move-head) var(--function-easing) infinite;
			z-index: 3;
			&:before, &:after {
				@include helper-pseudo-content-block;
				position: relative;
				@include size(15px);
				background-color: var(--black);
				border-radius: 50%;
				animation: blinkingEyes var(--duration-move-head) var(--function-easing) infinite;
			}
		}
		.granddad__nose, .granddad__ear {
			position: absolute;
			top: 100px;
			@include size(25px, 50px);
			border-radius: 20px;
			background-color: var(--skin);
			transform-origin: center 0;
		}
		.granddad__nose {
			left: 75px;
			animation: var(--animation-name-common-move) var(--duration-move-head) var(--function-easing) infinite;
			z-index: 3;
		}
		.granddad__ear {
			&--left {
				left: -15px;
				animation: visibleLeftEar var(--duration-move-head) var(--function-easing) infinite;
			}
			&--right {
				right: -15px;
				z-index: 3;
				animation: visibleRightEar var(--duration-move-head) var(--function-easing) infinite;
			}
		}
		.granddad__hat {
			position: absolute;
			top: -20px;
			left: -10px;
			animation: var(--animation-name-common-move) var(--duration-move-head) var(--function-easing) infinite;
			z-index: 3;
			&:before {
				@include helper-pseudo-content-block;
				position: absolute;
				bottom: -13px;
				left: 30px;
				@include size(110px, 17px);
				background-color: var(--hat);
				border-radius: 0 0 20px 20px;
				animation: moveVisor var(--duration-move-head) var(--function-easing) infinite;
			}
			&:after {
				position: relative;
				@include helper-pseudo-content-block;
				@include size(200px, 64px);
				background-color: #a6968e;
				background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 100 100'%3E%3Crect x='0' y='0' width='79' height='79' fill='%23b2a39d'/%3E%3C/svg%3E");
				background-attachment: fixed;
				border-radius: 30px;
			}
		}
	}
}

@keyframes moveForest {
	0% {
		transform: translateX(-100%);
	}
	100% {
		transform: translateX(0%);
		
	}
}
@keyframes moveCars {
	0% {
		transform: translateX(0%);
	}
	100% {
		transform: translateX(-100%);
	}
}
// car
@keyframes blinkTurnSignal {
	0% {
		filter: grayscale(0);
	}
	50% {
		filter: grayscale(1);
	}
	100% {
		filter: grayscale(0);
	}
}
@keyframes jumpCar {
	0% {
		transform: translateY(-1px);
	}
	100% {
		transform: translateY(1px);
	}
}
@keyframes moveCar {
	0% {
		left: -17px;
	}
	100% {
		left: -10px;
	}
}
@keyframes moveBlick {
	0% {
		transform: skew(60deg) translateX(-200px);
	}
	100% {
		transform: skew(60deg) translateX(100vw);
	}
}
@keyframes moveFrontBlick {
	0% {
		transform: skew(50deg) translate(0, 0);
	}
	100% {
		transform: skew(50deg) translate(700px, -300px);
	}
}
// granddad
@keyframes moveHand {
	0% {
		transform: translate(10px, 30px);
	}
	100% {
		transform: translate(0px, 20px);
	}
}
@keyframes blinkingEyes {
  0% {
    top: 0px;
    height: 15px;
  }
  5% {
    top: 0px;
    height: 15px;
  }
	90% {
		top: 0px;
    height: 15px; 
	}
  95% {
    top: 10px;
    height: 5px;
  }
 	100% {
    top: 0px;
    height: 15px;
  }
}
@keyframes jumpHead {
	0% {
		transform: translateY(-3px);
	}
	100% {
		transform: translateY(3px);
	}
}
@keyframes moveHead {
	0% {
		left: -20px;
	}
	25% {
		left: -20px;
	}
	40% {
		left: -20px;
	}
	60% {
		left: 5px;
	}
	75% {
		left: 5px;
	}
	90% {
		left: 5px;
	}
	100% {
		left: -20px;
	}
}
@keyframes jumpNeck {
	0% {
		transform: rotate(-40deg) translate(0, -1px);
	}
	100% {
		transform: rotate(-40deg) translate(-1px, 1px);
	}
}
@keyframes moveHeadPieces {
	0% {
		transform: translateX(-20px);
	}
	25% {
		transform: translateX(-20px);
	}
	40% {
		transform: translateX(-20px);
	}
	60% {
		transform: translateX(15px);
	}
	75% {
		transform: translateX(15px);
	}
	90% {
		transform: translateX(15px);
	}
	100% {
		transform: translateX(-20px);
	}
}
@keyframes moveVisor {
	0% {
		transform: translateX(-5px);
	}
	25% {
		transform: translateX(-5px);
	}
	40% {
		transform: translateX(-5px);
	}
	60% {
		transform: translateX(30px);
	}
	75% {
		transform: translateX(30px);
	}
	90% {
		transform: translateX(30px);
	}
	100% {
		transform: translateX(-5px);
	}
}
@keyframes moveTongue {
	0% {
		transform: translateX(12px);
	}
	25% {
		transform: translateX(12px);
	}
	40% {
		transform: translateX(12px);
	}
	60% {
		transform: translateX(-8px);
	}
	75% {
		transform: translateX(-8px);
	}
	90% {
		transform: translateX(-8px);
	}
	100% {
		transform: translateX(12px);
	}
}
@keyframes scaleMouth {
	0% {
		transform: scale(.95);
	}
	100% {
		transform: scale(1);
	}
}
@keyframes visibleLeftEar {
	0% {
		z-index: 1;
	}
	25% {
		z-index: 1;
	}
	40% {
		z-index: 1;
	}
	60% {
		z-index: 3;
	}
	75% {
		z-index: 3;
	}
	90% {
		z-index: 3;
	}
	100% {
		z-index: 1;
	}
}
@keyframes visibleRightEar {
	0% {
		z-index: 3;
	}
	25% {
		z-index: 3;
	}
	40% {
		z-index: 3;
	}
	60% {
		z-index: 1;
	}
	75% {
		z-index: 1;
	}
	90% {
		z-index: 1;
	}
	100% {
		z-index: 3;
	}
}

              
            
!

JS

              
                'use strict';

// shot from https://dribbble.com/shots/6274820-Fast-Lane

              
            
!
999px

Console