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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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 For best view please use Chrome!
#robot
#head
.front
.back
.left
.right
#torso
.front
.back
.left
.right
#left_arm
.upper_arm
.front
.back
.left
.right
.top
.bottom
.forearm
.front
.back
.left
.right
.top
.bottom
#right_arm
.upper_arm
.front
.back
.left
.right
.top
.bottom
.forearm
.front
.back
.left
.right
.top
.bottom
#left_leg
.thigh
.front
.back
.left
.right
.top
.bottom
.lower_leg
.front
.back
.left
.right
.top
.bottom
#right_leg
.thigh
.front
.back
.left
.right
.top
.bottom
.lower_leg
.front
.back
.left
.right
.top
.bottom
@import compass
$bg: #f6f5f1
$front: #9aacb1
$back: $front
$left: lighten($front, 10%)
$right: $left
$top: darken($front, 5%)
$bottom: $top
/* -------------------------------------
* Style
* ------------------------------------- */
body
padding: 50px
background: radial-gradient(1000px, $bg, darken($bg, 20%))
background-repeat: no-repeat
background-attachment: fixed
h1
color: $front
font: 24px Verdana, sans-serif
font-weight: normal
#robot
width: 300px
height: 620px
margin: 50px auto 0
position: relative
transform-style: preserve-3d
transform-origin: 50% 0 -30px
animation: spin 60s linear infinite
/*------- robot body -------*/
#head
width: 60px
height: 60px
position: absolute
top: 0
left: 120px
#torso
width: 200px
height: 230px
position: absolute
top: 80px
left: 50px
// arms
#left_arm
width: 25px
height: 240px
position: absolute
top: 110px
left: 30px
#right_arm
width: 25px
height: 240px
position: absolute
top: 110px
right: 30px
.upper_arm
width: 25px
height: 100px
position: relative
transform-style: preserve-3d // firefox
.forearm
width: 25px
height: 120px
margin-top: 20px
// legs
#left_leg
width: 30px
height: 340px
position: absolute
top: 280px
left: 85px
#right_leg
width: 30px
height: 340px
position: absolute
top: 280px
right: 85px
.thigh
width: 30px
height: 150px
position: relative
transform-style: preserve-3d //firefox
.lower_leg
width: 30px
height: 170px
margin-top: 20px
/*------- 3d effects -------*/
.front
width: inherit
height: inherit
background: $front
position: absolute
.back
width: inherit
height: inherit
background: $back
position: absolute
.left
width: inherit
height: inherit
position: absolute
background: $left
transform-origin: 0 0 0
transform: rotateY(90deg)
.right
width: inherit
height: inherit
position: absolute
background: $right
transform-origin: 100% 0 0
transform: rotateY(-90deg)
.top
width: inherit
background: $top
position: absolute
transform-origin: 0 0 0
transform: rotateX(-90deg)
.bottom
width: inherit
background: $top
position: absolute
transform-origin: 0 0 0
transform: rotateX(-90deg)
#head
transform-style: preserve-3d
transform-origin: 50% 0 -30px
animation: torso 0.8s ease-in-out infinite alternate
.back
transform: translateZ(-60px)
#torso
transform-style: preserve-3d
transform-origin: 50% 0 -30px
animation: torso 0.8s ease-in-out infinite alternate
.front
width: 0
height: 0
background: none
border-top: 230px solid $front
border-left: 100px solid transparent
border-right: 100px solid transparent
.back
width: 0
height: 0
background: none
border-top: 230px solid $back
border-left: 100px solid transparent
border-right: 100px solid transparent
transform: translateZ(-60px)
.left
width: 60px
height: 250px
transform: rotateY(90deg) rotateX(23.5deg)
.right
width: 60px
height: 250px
transform: rotateY(-90deg) rotateX(23.5deg)
right: 0
#left_arm, #right_arm
transform-style: preserve-3d
transform-origin: 0 0 -10px
animation: arm 0.8s ease-in-out infinite alternate
.back
transform: translateZ(-25px)
.top
height: 25px
.bottom
height: 25px
bottom: -25px
#right_arm
animation-delay: 0.8s
.forearm
animation-delay: 0.8s
.forearm
transform-style: preserve-3d
transform-origin: 0 0 0
animation: forearm 0.8s ease-in-out infinite alternate
#left_leg, #right_leg
transform-style: preserve-3d
transform-origin: 0 0 -20px
animation: leg 0.8s ease-in-out infinite alternate
.back
transform: translateZ(-30px)
.top
height: 30px
.bottom
height: 30px
bottom: -30px
#left_leg
animation-delay: 0.8s
.lower_leg
animation-delay: 0.8s
.lower_leg
transform-style: preserve-3d
transform-origin: 0 0 0
animation: lower_leg 0.8s ease-in-out infinite alternate
/*------- animation -------*/
@keyframes spin
0%
transform: rotateY(0deg)
100%
transform: rotateY(360deg)
@keyframes torso
0%
transform: rotateY(-7deg)
100%
transform: rotateY(7deg)
@keyframes arm
0%
transform: rotateX(-15deg) translateZ(-20px) // note
100%
transform: rotateX(20deg) translateZ(-20px) // note
@keyframes forearm
0%
transform: rotateX(0deg)
100%
transform: rotateX(60deg)
@keyframes leg
0%
transform: rotateX(-5deg) translateZ(-15px) // note
100%
transform: rotateX(25deg) translateZ(-15px) // note
@keyframes lower_leg
0%
transform: rotateX(0deg) translateY(15px)
100%
transform: rotateX(-50deg) translateY(15px)
// note: should remove translateZ for Safari. It is really weird that Safari and Chrome use different method to treat transform-origin property.
Also see: Tab Triggers