HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
%h1 Johnny Five
%h2 Click & hold anywhere to activate
.five
.head
.antenna
.controller
.lid
.lid.right
.lid-extra
.eye.left
.outer
.inner
.zoom
.rim
.pupil
.center-eyes
.join.left
.join.right
.eye.right
.outer
.inner
.zoom
.rim
.pupil
.shadows
.mouth-area
.mouth
.lower-lids
.lower-connect.left
.lower-connect.right
.lower-lid.left
.lower-lid.right
.neck
.rect
.join
.rect.right
.join
.center-neck-top
.center-neck
.bottom-neck
.tri
.pipe.one
.pipe.two
.pipe.three
.pipe-large.one
.pipe-large.two
.shoulders
.shoulder-pipe
.main
.gun
.gap.left
.gap.right
.circle
.arm.left
.top
.shoulder
.cap
.bicep
.arm.right
.top
.shoulder
.cap
.bicep
.body
.pack
.panel
.blue-panel
@import "compass/css3";
@import "compass/css3/user-interface";
@import url(https://fonts.googleapis.com/css?family=Raleway:200);
@mixin transform($x, $y, $z) {
-webkit-transform: rotateX($x) rotateY($y) rotateZ($z);
-moz-transform: rotateX($x) rotateY($y) rotateZ($z);
transform: rotateX($x) rotateY($y) rotateZ($z);
}
$bgCol: #bbbbbb;
$lidCol: #222222;
$lowerlidCol: #222222;
body {
background: $bgCol;
font-family: 'Raleway', Helvetica, Arial, sans-serif;
}
h1, h2 {
font-size: 70px;
text-align: center;
font-weight: 200;
margin: 30px 0;
text-transform: uppercase;
background:-webkit-linear-gradient(#777, #111);
-webkit-background-clip:text;
-webkit-text-fill-color:transparent;
@include user-select(none);
}
h2 {
font-size: 26px;
}
:before, :after {
content: "";
position: absolute;
display: block;
}
.five {
width: 500px;
position: relative;
left: 50%;
top: 80px;
margin-left: -250px;
@include user-select(none);
}
.head {
background-color: #777777;
@include filter-gradient(#999999, #999999, horizontal);
@include background-image(linear-gradient(left, #999999 0%, #888888 40%, #888888 60%, #999999 100%));
width: 490px;
height: 170px;
position: relative;
z-index: 3;
@include border-radius(6px);
&:before, &:after {
background: #999999;
width: 17%;
height: 50%;
bottom: -15%;
@include border-radius(6px);
}
&:after {
right: -2px;
@include transform(0deg, 0deg, 4deg);
}
.antenna {
position: absolute;
left: 5%;
top: -15px;
background: #aaaaaa;
height: 8px;
width: 20px;
&:before {
left: -3px;
top: 8px;
background: #8a8a8a;
height: 7px;
width: 26px;
}
&:after {
left: 3px;
top: -15px;
background: #7e685c;
height: 15px;
width: 14px;
}
}
.controller {
position: absolute;
top: -30px;
right: 20%;
width: 0px;
height: 0px;
border-style: solid;
border-width: 0 0 30px 15px;
border-color: transparent transparent #666666 transparent;
&:before {
background: #555555;
width: 40px;
left: -20px;
top: 0;
height: 8px;
@include transform(0deg, 0deg, 4deg);
}
}
}
/* Eyes */
.eye {
width: 150px;
height: 150px;
position: absolute;
background: #000000;
border: 2px solid #444444;
bottom: 1%;
z-index: 1;
@include border-radius(100%);
&:before, &:after {
border-style: solid;
width: 0;
height: 0;
}
&.left {
left: 1%;
@include box-shadow(-3px -2px 2px 0 #333333);
&:before {
top: 25px;
left: -10%;
border-width: 35px 20px 0 0;
border-color: #888888 transparent transparent transparent;
}
&:after {
top: 15px;
left: -13%;
border-width: 35px 20px 0 0;
border-color: #888888 transparent transparent transparent;
}
}
&.right {
right: 1%;
@include box-shadow(3px -2px 2px 0 #333333);
&:before {
top: 25px;
right: -10%;
border-width: 0 20px 35px 0;
border-color: transparent #888888 transparent transparent;
}
&:after {
border-width: 0 20px 35px 0;
border-color: transparent #888888 transparent transparent;
top: 15px;
right: -13%;
}
.pupil:after {
left: 15px;
}
}
.outer, .inner, .zoom, .rim, .pupil {
background: #000000;
position: absolute;
@include border-radius(100%);
}
.outer {
top: 1px;
left: 1px;
width: 140px;
height: 140px;
border: 4px solid #7e685c;
}
.inner {
top: 9px;
left: 9px;
width: 120px;
height: 120px;
border: 6px solid #584035;
}
.zoom {
top: 16px;
left: 16px;
width: 110px;
height: 110px;
background: #89653c;
border: 4px solid #cea26f;
}
.rim {
top: 30px;
left: 30px;
width: 90px;
height: 90px;
background: #54554d;
@include box-shadow(inset 0 0 2px 2px #333333);
}
.pupil {
top: 52px;
left: 50px;
width: 50px;
height: 50px;
@include transition(all .3s ease-in-out);
&:after {
background: #cccccc;
width: 10px;
height: 10px;
bottom: 2px;
left: 20px;
@include border-radius(100%);
@include transition(all .3s ease-in-out);
}
}
}
/* Eyelids */
.lid {
background: $lidCol;
display: block;
position: absolute;
width: 180px;
padding: 20px;
z-index: 100;
height: 60px;
top: -20px;
left: -40px;
@include box-shadow(5px 10px 20px -8px black);
@include transform(70deg, -4deg, 0deg);
@include border-radius(30px 15px);
@include transition(all .3s ease-in-out);
&:after {
background: $lidCol;
width: 90px;
height: 55px;
top: 0;
right: -60px;
@include border-radius(15px);
}
&.right {
left: auto;
height: 50px;
right: -40px;
@include transform(70deg, 3deg, 0deg);
@include border-radius(15px 30px);
&:after {
left: -60px;
}
&:before {
background: $lidCol;
width: 60px;
height: 55px;
bottom: -10px;
right: 0;
@include border-radius(10px);
}
.lid-extra {
background: $lidCol;
width: 60px;
height: 55px;
position: absolute;
bottom: -10px;
right: 0;
@include border-radius(10px);
right: auto;
left: 0;
}
}
}
.center-eyes {
background-color: #444444;
@include filter-gradient(#999999, #999999, vertical);
@include background-image(linear-gradient(top, #999999 0%,#777777 35%,#777777 50%,#777777 65%,#999999 100%));
position: absolute;
left: 40%;
top: 10px;
width: 20%;
height: 60%;
@include border-radius(4px);
@include box-shadow(0 0 9px #777777);
&:before {
background: #222222;
height: 10px;
width: 90%;
top: 30px;
left: 5px;
@include border-radius(2px);
@include box-shadow(inset 0 0 4px #222222);
}
.join {
background: #5a5a5a;
height: 29px;
width: 16px;
display: block;
position: absolute;
top: 10px;
&.left {
left: 10px;
}
&.right {
right: 10px;
}
}
}
.shadows {
position: relative;
top: 60px;
left: 160px;
height: 80px;
width: 170px;
&:before, &:after {
background: #888888;
width: 125px;
height: 70px;
z-index: -1;
@include border-radius(10px);
@include box-shadow( 0 0 4px #666666);
}
&:before {
top: 10px;
left: -100px;
@include transform(0deg, 0deg, -20deg);
}
&:after {
top: 10px;
right: -100px;
@include transform(0deg, 0deg, 20deg);
}
}
.mouth-area {
background: #777777;
width: 140px;
height: 20px;
position: absolute;
top: 88%;
left: 34.5%;
padding: 14px 5px 10px;
border-top: 2px solid #666666;
@include border-radius(0 0 6px 6px);
&:before {
background: #777777;
width: 165px;
height: 16px;
top: -10px;
left: -8px;
z-index: -1;
@include box-shadow(inset 0 0 4px #555555);
}
.mouth {
background: #222222;
border-top: 2px solid #777777;
width: 100%;
height: 12px;
&:before, &:after {
bottom: -6px;
background: #777777;
height: 20px;
width: 30px;
}
&:before {
left: 0;
@include border-radius(0px 0px 20px 4px);
}
&:after {
right: 0;
@include border-radius(0px 0px 4px 20px);
}
}
}
.lower-lids {
position: absolute;
top: 100%;
width: 100%;
.lower-lid {
background: $lowerlidCol;
display: block;
position: absolute;
width: 110px;
padding: 20px;
z-index: 10;
top: -26px;
height: 60px;
@include box-shadow(5px 10px 20px -8px black);
@include transform(-80deg, -2deg, 0deg);
@include border-radius(30px 15px);
@include transition(all .3s ease-in-out);
&:after {
background: $lowerlidCol;
width: 50px;
height: 60px;
bottom: 0;
right: -26px;
@include border-radius(12px);
}
&.left {
left: -10px;
}
&.right {
right: -10px;
@include transform(-80deg, -2deg, 0deg);
@include border-radius(15px 30px);
&:after {
left: -26px;
}
}
}
.lower-connect {
background: #333;
height: 18px;
width: 14px;
position: absolute;
z-index: 11;
border-bottom: 3px solid #444444;
&.left {
left: 18%;
@include transform(0deg, 0deg, 2deg);
}
&.right {
right: 18%;
@include transform(0deg, 0deg, 4deg);
}
}
}
/* Neck */
.neck {
position: relative;
&:before {
z-index: 10;
left: 40%;
width: 90px;
top: 164px;
height: 6px;
background: #222222;
@include border-radius(4px 4px 0 0);
}
}
.rect {
background: #b67b41;
width: 40px;
height: 100px;
float: left;
margin: 50px 40px;
position: relative;
left: 125px;
z-index: 2;
@include border-radius(4px);
@include transform(0deg, 0deg, -30deg);
&.right {
@include transform(0deg, 0deg, 30deg);
}
&:before, &:after {
width: 25px;
left: 8px;
}
&:before {
background: #222222;
height: 80px;
top: -80px;
}
&:after {
background: #4a4a4a;
height: 40px;
top: 100px;
}
.join {
background: #a9a9a9;
height: 46px;
width: 40px;
position: absolute;
top: -82px;
}
}
.center-neck-top {
background: #333333;
width: 35px;
height: 30px;
position: absolute;
top: 22px;
left: 45%;
&:before, &:after {
height: 60px;
}
&:before {
width: 10px;
background: #555555;
left: -20px;
top: -10px;
@include transform(0deg, 0deg, -30deg);
}
&:after {
top: -10px;
right: -20px;
width: 8px;
background: #666666;
@include transform(0deg, 0deg, 30deg);
}
}
.center-neck {
position: absolute;
left: 41%;
display: block;
z-index: 1;
width: 80px;
top: 60px;
height: 140px;
background: #222222;
@include border-radius(4px);
&:before {
left: -5px;
z-index: 1;
width: 90px;
top: -10px;
height: 30px;
background: #222222;
border-bottom: 1px solid #111111;
@include border-radius(4px);
}
}
.bottom-neck {
background: #888888;
width: 110px;
height: 80px;
position: absolute;
top: 170px;
left: 38%;
z-index: 10;
@include border-radius(4px);
&:before {
background: #999999;
width: 60px;
height: 40px;
bottom: 0;
left: 22%;
@include border-radius(4px);
@include box-shadow(0 -4px 4px 3px #aaaaaa);
}
}
.tri {
position: absolute;
top: 240px;
left: 39%;
z-index: 1;
.pipe {
background: #222222;
height: 205px;
width: 20px;
display: block;
float: left;
margin-right: 20px;
position: relative;
&:before, &:after {
background: #cccccc;
height: 40px;
width: 30px;
left: -5px;
}
&:before {
top: -10px;
}
&:after {
bottom: 5px;
}
&.one {
top: -50px;
left: -15px;
}
&.two {
height: 190px;
&:before {
top: 0;
left: -10px;
width: 40px;
}
&:after {
bottom: 0;
}
}
&.three {
top: -50px;
right: -15px;
}
}
}
.pipe-large {
&.one {
border: 30px solid #000000;
border-left-color: transparent;
border-bottom-color: transparent;
position: absolute;
top: 100px;
right: 25px;
width: 310px;
height: 320px;
@include border-radius(100%);
@include transform(0deg, 0deg, 40deg);
&:before {
border-left: 6px solid #000000;
top: -2px;
right: 30px;
height: 260px;
width: 140px;
@include border-radius(100%);
@include transform(0deg, 0deg, 110deg);
}
}
&.two {
border: 30px solid #000000;
border-left-color: transparent;
border-bottom-color: transparent;
position: absolute;
top: 88px;
right: -40px;
height: 280px;
width: 360px;
@include border-radius(100%);
@include transform(0deg, 0deg, 50deg);
}
}
.shoulders {
background-color: #555555;
@include filter-gradient(#555555, #555555, vertical);
@include background-image(linear-gradient(top, #555555 0%,#e8e8e8 15%,#cecece 16%,#cecece 16%,#555555 100%));
height: 60px;
width: 450px;
position: absolute;
top: 560px;
z-index: 13;
left: -50px;
@include border-radius(10px 10px 0 0);
&:before {
background: #999999;
width: 140px;
height: 35px;
bottom: 0;
left: 50%;
z-index: -3;
@include border-radius(4px 4px 0 0);
@include box-shadow(0 -4px 4px 3px #aaaaaa);
}
.shoulder-pipe {
background: #cccccc;
content: "";
height: 45px;
width: 26px;
position: absolute;
bottom: 4px;
left: 62.6%;
&:before {
background: #222222;
left: 3px;
top: -11px;
width: 20px;
height: 10px;
z-index: 0;
}
&:after {
top: -11px;
height: 60px;
left: -3px;
width: 32px;
background: #000000;
z-index: -1;
}
}
.main {
background-color: #555555;
@include filter-gradient(#555555, #555555, vertical);
@include background-image(linear-gradient(top, #555555 0%,#cecece 40%,#cecece 45%,#555555 100%));
height: 120px;
width: 850px;
position: absolute;
top: 60px;
z-index: 13;
left: -100px;
.gun {
background-color: #4c4c4c;
@include filter-gradient(#4c4c4c, #262626, vertical);
@include background-image(linear-gradient(top, #4c4c4c 0%,#2c2c2c 42%,#232323 69%,#262626 100%));
height: 150px;
width: 270px;
position: absolute;
right: -50px;
top: -170px;
@include border-radius(4px);
&:before {
background: #000000;
width: 262px;
height: 6px;
top: 40%;
left: 4px;
@include border-radius(2px);
@include transition(all .3s .05s ease-in-out);
}
&:after {
top: 100%;
background: #333333;
width: 110px;
height: 20px;
left: 30%;
}
}
.gap {
background: $bgCol;
height: 100px;
width: 260px;
margin: 10px 0 10px 8%;
position: relative;
display: block;
overflow: hidden;
@include border-radius(50px);
@include box-shadow(inset 0 0 10px 0 #000000);
float: left;
&.left:before {
background: #777777;
height: 100%;
width: 10px;
left: 20px;
border-left: 5px solid #a9a9a9;
border-right: 15px solid #555555;
}
&.left:after {
background: #222222;
height: 100%;
width: 90px;
left: 48px;
@include transition(all .3s ease-in-out);
}
&.right {
float: right;
margin-right: 22%;
width: 190px;
&:before {
border-left: 6px solid #000000;
top: -2px;
left: -30px;
height: 260px;
width: 140px;
@include border-radius(100%);
@include transform(0deg, 0deg, 110deg);
}
.circle {
background: #222222;
position: absolute;
height: 100%;
width: 100px;
top: 0;
right: 0;
@include border-radius(100%);
@include transition(all .3s ease-in-out);
&:after {
background: darkred;
width: 10px;
height: 10px;
bottom: 15%;
left: 30%;
border: 6px solid #FFFFFF;
@include border-radius(100%);
}
}
}
}
}
.arm {
position: absolute;
top: 60px;
z-index: 15;
.top {
background: #999999;
height: 120px;
width: 120px;
overflow: hidden;
position: absolute;
@include border-radius(100%);
&:before {
background: #cccccc;
height: 80px;
width: 100px;
top: 10px;
border: 10px solid #aaaaaa;
border-left: none;
border-right: none;
@include box-shadow(0 0 4px 0 #000000);
}
}
.shoulder {
background-color: #555555;
@include filter-gradient(#555555, #555555, vertical);
@include background-image(linear-gradient(top, #555555 0%,#cecece 40%,#cecece 45%,#555555 100%));
height: 114px;
width: 130px;
position: absolute;
z-index: 16;
top: 3px;
@include box-shadow(2px 4px 10px -3px #000000);
&:before {
background-color: #777777;
@include filter-gradient(#999999, #999999, vertical);
@include background-image(linear-gradient(top, #555555 0%,#bbbbbb 40%,#bbbbbb 45%,#999999 100%));
height: 100%;
width: 50%;
right: 0;
}
.cap {
background-color: #888888;
@include filter-gradient(#888888, #888888, vertical);
@include background-image(linear-gradient(top, #888888 0%,#cccccc 40%,#888888 100%));
width: 30px;
position: absolute;
top: -3px;
height: 122px;
&:before {
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
height: 70px;
width: 0;
top: 6px;
}
}
.bicep {
background-color: #666666;
@include filter-gradient(#666666, #666666, vertical);
@include background-image(linear-gradient(left, #666666 0%, #dddddd 55%, #dddddd 60%, #666666 100%));
width: 118px;
height: 80px;
border-top: 4px solid #444444;
position: absolute;
top: 72%;
left: 4px;
@include border-radius(100% 100% 0 0);
&:before {
background-color: #000000;
@include filter-gradient(#000000, #333333, vertical);
@include background-image(linear-gradient(left, #000000 0%, #333333 55%, #333333 60%, #000000 100%));
height: 25px;
width: 108%;
top: 100%;
left: -5px;
}
&:after {
background-color: #666666;
@include filter-gradient(#666666, #666666, vertical);
@include background-image(linear-gradient(left, #666666 0%, #dddddd 55%, #dddddd 60%, #666666 100%));
width: 118px;
height: 36px;
position: absolute;
top: 131%;
left: 0;
}
}
}
&.left {
left: -160px;
.top:before {
right: 0;
}
.shoulder {
left: -60px;
@include border-radius(0 10px 10px 0);
&:before {
border-left: 4px solid #444444;
@include border-radius(0 10px 10px 0);
}
.cap {
right: 100%;
&:before {
border-right: 80px solid #aaaaaa;
right: 100%;
}
}
}
}
&.right {
right: -240px;
.shoulder {
left: 50px;
@include border-radius(10px 0 0 10px);
@include box-shadow(-2px 4px 10px -3px #000000);
&:before {
left: 0;
border-right: 4px solid #444444;
@include border-radius(10px 0 0 10px);
}
.cap {
left: 100%;
&:before {
border-left: 80px solid #aaaaaa;
left: 100%;
}
}
}
}
}
}
.body {
background-color: #555555;
@include filter-gradient(#555555, #999999, vertical);
@include background-image(linear-gradient(top, #555555 0%, #999999 100%));
width: 320px;
position: absolute;
top: 740px;
height: 110px;
left: 50px;
@include box-shadow(inset 0 14px 10px -10px #000000);
&:before {
background: #999999;
height: 100px;
width: 138px;
top: 0;
left: 38.5%;
border-left: 8px solid #aaaaaa;
border-right: 8px solid #aaaaaa;
border-bottom: 3px solid #888888;
}
.pack {
background-color: #666666;
@include filter-gradient(#666666, #333333, vertical);
@include background-image(linear-gradient(top, #666666 0%,#555555 23%,#3f3f3f 24%,#212121 55%,#555555 55%,#333333 100%));
width: 140px;
position: absolute;
top: 0;
height: 110px;
left: -170px;
}
.panel {
background: #999999;
height: 95px;
width: 116px;
position: absolute;
top: 0;
z-index: 13;
left: 42%;
border-left: 8px solid #aaaaaa;
border-right: 8px solid #aaaaaa;
.blue-panel {
background: #8c9cad;
height: 100px;
width: 100px;
left: 0;
position: absolute;
top: -40px;
border: 8px solid #aaaaaa;
border-top: 22px solid #888888;
border-bottom: 5px solid #888888;
@include border-radius(8px);
&:before {
background-color: #555555;
@include filter-gradient(#555555, #555555, vertical);
@include background-image(linear-gradient(top, #555555 0%,#e8e8e8 15%,#cecece 16%,#cecece 16%,#555555 100%));
top: -102px;
width: 80px;
height: 86px;
left: 2px;
border-left: 8px solid #444444;
border-right: 8px solid #444444;
}
}
}
}
/* Active */
html:active {
.iris {
background-size: 120%;
}
.lid {
top: -20px;
@include transform(10deg, 0deg, 10deg);
&.right {
@include transform(10deg, 0deg, -10deg);
}
}
.eye {
.rim {
background: #222222;
}
.pupil {
background: red;
@include box-shadow(0 0 16px red);
@include transform(0deg, 0deg, 360deg);
&:after {
opacity: 0;
}
}
}
.lower-lid {
top: -54px;
z-index: 12;
&.left {
@include transform(-130deg, 0deg, 2deg);
}
&.right {
@include transform(-130deg, 0deg, -2deg);
}
}
.shoulders .main .gun:before {
background: red;
@include box-shadow(0 0 16px red);
}
.shoulders .main .gap.right .circle {
@include transform(0deg, 0deg, -200deg);
right: 40px;
}
.shoulders .main .gap.left:after {
width: 120px;
}
}
Also see: Tab Triggers