JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
<div id="landscape">
<div class="sun"></div>
<div class="cloud first"></div>
<div class="cloud second"></div>
<div class="cloud third"></div>
<div class="bird first"><span></span></div>
<div class="bird second"><span></span></div>
<div class="bird third"><span></span></div>
<div class="tree small a"><span></span></div>
<div class="tree big e"><span></span></div>
<div class="tree small i"><span></span></div>
<div class="tree big o"><span></span></div>
<div class="tree small u"><span></span></div>
<div class="fatty">
<div class="head">
<div class="hat">
<div class="visor"></div>
</div>
</div>
<div class="body">
<div class="left-arm"></div>
<div class="right-arm"></div>
<div class="right-leg"></div>
<div class="left-leg"></div>
</div>
</div>
</div>
// Constants
$ground: 30;
$turf: 20;
$cloud: 80;
$sun: 150;
$birdSize: 25;
$tree: 100;
$fatty: 400;
$sunColor: rgb(255, 196, 0);
$cloudColor: rgba(255, 255, 255, 0.9);
$skyColor: rgb(110, 219, 225);
$groundColor: rgb(105,213,146);
$turfColor: rgb(69,130,92);
$skinColor: rgb(254,227,187);
$hatColor: rgb(252,50,80);
$pantsColor: rgb(51,172,224);
$shirtColor: rgb(99,225,253);
// Animations
// Bird's wind
@keyframes wingFlop {
0% {
height: $birdSize/2 +px;
transform: translateY(0);
}
33% {
height: 5px;
transform: translateY(0);
}
66% {
height: $birdSize/2 +px;
transform: translateY(-50%);
}
100% {
height: 5px;
transform: translateY(0);
}
}
@mixin birdFlight($name, $offset) {
@keyframes #{$name} {
0% {
right: -20%;
top: 10 + $offset + 1%;
}
10% {
top: 20 + $offset + 1%;
}
30% {
top: 10 + $offset + 1%;
}
60% {
top: 20 + $offset + 1%;
}
90% {
top: 10 + $offset + 1%;
}
99% {
top: 30 + $offset + 1%;
}
100% {
right: 120%;
}
}
}
// Avoid writing the keyframe 3 times
@include birdFlight(firstBird, 0);
@include birdFlight(secondBird, 1);
@include birdFlight(thirdBird, -1);
@keyframes trees {
from {
left: 120%;
}
to {
left: -120%;
}
}
@keyframes leftArm {
0% {
left: - $fatty/7 + px;
transform: rotate(60deg);
}
50% {
left: $fatty/40 + px;
transform: rotate(-5deg);
}
100% {
left: - $fatty/7 + px;
transform: rotate(60deg);
}
}
@keyframes rightArm {
0% {
right: 0;
top: 30%;
}
50% {
right: 60%;
top: 0;
}
100% {
right: 0;
top: 30%;
}
}
@keyframes rightLeg {
0% {
left: 15%;
bottom: -33%;
transform: rotate(0deg);
}
50% {
bottom: -17%;
left: -10%;
transform: rotate(37deg);
}
100% {
left: 15%;
bottom: -33%;
transform: rotate(0deg);
}
}
@keyframes leftLeg{
0% {
transform: rotate(50deg);
bottom: -23%;
left: 0;
}
50% {
transform: rotate(0);
bottom: -33%;
left: 10%;
}
100% {
transform: rotate(50deg);
bottom: -23%;
left: 0;
}
}
// Styles
#landscape {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background: $skyColor;
overflow: hidden;
&:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: $ground + px;
background: $groundColor;
}
&:after {
content: "";
position: absolute;
bottom: $ground + px;
left: 0;
width: 100%;
height: $turf + px;
background: $turfColor;
}
.sun {
width: $sun + px;
height: $sun + px;
border-radius: 100%;
background: $sunColor;
position: absolute;
right: -$sun/4 + px;
top: -$sun/4 + px;
}
.cloud {
width: $cloud + px;
height: $cloud + px;
border-radius: 100%;
background: $cloudColor;
position: absolute;
top: 15%;
left: 50%;
&:before {
content: "";
display: block;
width: $cloud - 10 + px;
height: $cloud - 10 + px;
border-radius: 100%;
background: $cloudColor;
position: absolute;
right: -60%;
top: 10%;
}
&:after {
content: "";
display: block;
width: $cloud - 10 + px;
height: $cloud - 10 + px;
border-radius: 100%;
background: $cloudColor;
position: absolute;
left: -60%;
top: 10%;
}
&.first {
top: 25%;
left: 15%;
}
&.third {
left: 85%;
top: 25%;
}
}
.bird {
position: absolute;
right: -5%;
width: $birdSize + px;
height: $birdSize + px;
border-radius: 100%;
background: rgb(16, 136, 235);
top: 15%;
// Wings
&:after {
content: "";
display: block;
width: $birdSize + px;
height: $birdSize/2 + px;
border-radius: 100%;
background: rgb(11, 112, 214);
position: relative;
top: 40%;
left: 30%;
animation: wingFlop 1s linear infinite;
}
// Eye
&:before {
content: "";
display: block;
width: $birdSize/6 + px;
height: $birdSize/6 + px;
position: absolute;
background: #fff;
border-radius: 100%;
left: 3px;
top: 5px;
}
// Beak
span {
display: block;
position: absolute;
width: 0;
height: 0;
border-top: ($birdSize/4 + px) solid transparent;
border-bottom: ($birdSize/4 + px) solid transparent;
border-right: ($birdSize/4 + px) solid rgb(235, 140, 16);
left: -($birdSize/4 - 2 + px);
top: 5px;
z-index: 0;
}
&.first {
animation: firstBird 6s linear infinite;
}
&.second {
animation: secondBird 6s linear infinite;
animation-delay: .1s;
}
&.third {
animation: thirdBird 6s linear infinite;
animation-delay: .2s;
}
}
// Trees
.tree {
$smallTree: $tree/2;
position: absolute;
bottom: $ground + $turf + px;
left: 150%;
background: rgb(135, 103, 5);
width: $tree/3 + px;
height: $tree/2 + px;
animation: trees 15s linear infinite;
&.e {
animation-delay: .5s;
}
&.i {
animation-delay: 7.8s;
}
&.o {
animation-delay: 8.5s;
}
&.u {
animation-delay: 8.9s;
}
// Log
&:before {
display: block;
content: "";
width: $tree + px;
height: $tree + px;
border-radius: 100%;
background: $turfColor;
position: absolute;
top: -180%;
left: -100%;
}
&:after {
display: block;
content: "";
width: $tree/2 + px;
height: $tree/2 + px;
border-radius: 100%;
background: $groundColor;
border: 1px solid $turfColor;
position: absolute;
top: -150%;
left: -150%;
}
&.small {
width: $smallTree/3 + px;
height: $smallTree/2 + px;
&:before {
width: $smallTree + px;
height: $smallTree + px;
}
&:after {
width: $smallTree/2 + px;
height: $smallTree/2 + px;
}
}
}
.fatty {
position: absolute;
left: 50%;
bottom: $ground + $turf + px;
width: $fatty + px;
height: ($fatty * .85) + px;
transform: translateX(-50%);
text-align: center;
.head {
width: $fatty/8 + px;
height: $fatty/4 + px;
background: $skinColor;
position: relative;
top: $fatty/16 + px;
left: 48%;
margin-left: -$fatty/16 + px;
// Perfect half moon head
&:before {
content: "";
display: block;
width: $fatty/8 + px;
height: $fatty/8 + px;
background: $skinColor;
border-radius: 100%;
top: -25%;
position: relative;
}
// Shade
&:after {
content: "";
display: block;
position: relative;
width: 0;
height: 0;
border-top: 0 + px solid transparent;
border-bottom: $fatty/16 + px solid transparent;
border-right: $fatty/8 + px solid rgba(0, 0, 0, 0.1);
top: -50%;
}
}
.hat {
position: absolute;
z-index: 2;
width: $fatty/8 + px;
height: $fatty/16 + px;
border-radius: $fatty/8 + px $fatty/8 + px 0 0;
background: $hatColor;
top: -$fatty/16 + px;
// Small inclination
&:before {
content: "";
display: block;
width: 0;
height: 0;
position: absolute;
box-sizing: border-box;
border-top: 0 + px solid transparent;
border-bottom: 5px solid transparent;
border-left: $fatty/8 + px solid $hatColor;
top: $fatty/16 + px
}
&:after {
content: "";
display: block;
width: $fatty/7 + px;
border-top: 3px solid $hatColor;
position: absolute;
left: -2px;
top: $fatty/15 + px;
transform: rotate(-5deg);
}
.visor {
width: 0;
height: 0;
position: absolute;
z-index: 3;
left: 60%;
top: 24px;
transform: rotate(-7deg);
border-top: 0 + px solid transparent;
border-bottom: $fatty/31 + px solid transparent;
border-left: $fatty/8 + px solid $hatColor;
&:before {
content: "";
display: block;
width: $fatty/16 + px;
height: $fatty/32 + px;
background: $hatColor;
position: absolute;
left: -$fatty/6 + px;
border-radius: 0 0 $fatty/16 + px $fatty/16 + px;
}
&:after {
content: "";
display: block;
position: absolute;
width: $fatty/16 + px;
height: $fatty/32 + px;
background: rgb(202,50,90);
border-radius: 0 0 $fatty/16 + px $fatty/16 + px;
left: -$fatty/17 + px;
top: 3px;
transform: rotate(-13deg);
}
}
}
.body {
position: relative;
width: $fatty/2 + px;
height: $fatty/2 + px;
border-radius: 100%;
background: $pantsColor;
left: 50%;
top: -$fatty/16 + px;
margin-left: -$fatty/4 + px;
// Shirt
&:before {
content: "";
display: block;
position: absolute;
top: 0;
left: -7%;
width: $fatty/2 + px;
height: $fatty/4 + px;
border-radius: $fatty/4 + px $fatty/4 + px 0 0;
background: $shirtColor;
box-sizing: border-box;
border-bottom: $fatty/12 +px solid $pantsColor;
transform: rotate(-15deg);
}
&:after {
content: "";
display: block;
background: $skinColor;
position: absolute;
width: $fatty/5 + px;
height: $fatty/8 + px;
border-radius: 100%;
left: 27%;
top: -2%;
transform: rotate(-5deg);
}
}
.left-arm {
position: relative;
width: $fatty/12 + px;
height: $fatty/12 + px;
border-radius: 100%;
background: $skinColor;
top: 20%;
left: 10%;
&:before {
content: "";
display: block;
position: absolute;
z-index: 4;
height: $fatty/4 + px;
width: $fatty/4 + px;
top: 70%;
left: -$fatty/7 + px;
border: solid;
border-width: 0 0 $fatty/24 + px $fatty/24 + px;
border-color: $skinColor;
border-radius: 0 0 10% 70%;
transform: rotate(60deg);
animation: leftArm 1s linear infinite;
}
}
.right-arm {
position: absolute;
right: 0;
top: 30%;
z-index: -1;
background: $skinColor;
height: $fatty/3 + px;
width: $fatty/28 + px;
border-radius: $fatty/30 + px $fatty/30 + px $fatty/30 + px 0;
transform: rotate(-40deg);
animation: rightArm 1s linear infinite;
}
.right-leg {
width: $fatty/3+ px;
height: $fatty/3 + px;
position: absolute;
z-index: -1;
bottom: -33%;
left: 15%;
border: solid;
border-width: $fatty/20 + px $fatty/20 + px 0 0;
border-color: $pantsColor;
border-radius: 0 100% 0 0;
animation: rightLeg 1s linear infinite;
}
.left-leg {
width: $fatty/3+ px;
height: $fatty/2 + px;
position: absolute;
z-index: -2;
bottom: -23%;
left: 0;
border: solid;
border-width: $fatty/20 + px $fatty/20 + px 0 0;
border-color: $pantsColor;
border-radius: 0 100% 0 0;
transform: rotate(50deg);
animation: leftLeg 1s linear infinite;
&:after {
content: "";
display: block;
position: absolute;
top: $fatty/12 + px;
right: -$fatty/40 + px;
width: $fatty/3 + px;
height: $fatty/4 + px;
border: solid;
border-width: $fatty/20 + px $fatty/20 + px 0 0;
border-color: rgba(0, 0, 0, 0.2);
border-radius: 0 100% 0 0;
transform: rotate(-5deg);
}
}
}
}
Also see: Tab Triggers