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.
- var objects = ['line lineOne', 'line lineTwo', 'line lineThree', 'stand', 'weight', 'cabin', 'arm']
- var n = 0
#content
h1 < building />
p Working day and night!
#outerCraneContainer
.buildings
while n < 5
div(class= n++)
.crane.craneThree
for i in objects
div(class= i)
.crane.craneTwo
for i in objects
div(class= i)
.crane.craneOne
for i in objects
div(class= i)
a(rel='license' href='http://creativecommons.org/licenses/by-nc-sa/4.0/' id='license')
img(alt='Creative Commons License' style='border-width:0' src='https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png')
// Please respect a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. That means only share and adapt giving a fair credit and do not use for commercial projects. Thank you.
@import url('https://fonts.googleapis.com/css?family=Ubuntu')
$craneWidth = 260px
$craneHeight = $craneWidth / 1.53
$craneBorder = 1px
$teal = rgba(68, 192, 166, 1)
$purp = rgba(64, 42, 79, 1)
$cityColor = tomato
#outerCraneContainer
position absolute
width 100%
height 100%
bottom 0
overflow hidden
display flex
justify-content center
box-shadow inset 0 -60px 0 -30px $cityColor
.buildings
height ($craneHeight / 2)
width 100%
left 0
div
height inherit
width ($craneHeight / 4)
background $cityColor
position absolute
bottom 10%
&:after
content ''
width 80%
height 60%
left 10%
bottom 30%
background url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAFElEQVQImWP4////fwYYIJKDEwAAfPsP8eFXG40AAAAASUVORK5CYII=') repeat
position absolute
.buildings div:nth-of-type(1)
width ($craneHeight / 4)
height ($craneHeight / 8)
right 37%
bottom 18%
&:after
bottom 11%
.buildings div:nth-of-type(2)
width ($craneHeight / 3.5)
height ($craneHeight / 6)
right 30%
bottom 35%
transform rotate(180deg)
&:after
width 60%
left 11%
.buildings div:nth-of-type(3)
width ($craneHeight / 7)
height ($craneHeight / 4.5)
left 40%
bottom 35%
&:after
bottom 0
width 20%
height 85%
left 70%
.buildings div:nth-of-type(4)
width ($craneHeight / 2)
height ($craneHeight / 8)
left 24%
bottom 20%
&:after
background none
.buildings div:nth-of-type(5)
width ($craneHeight / 2.75)
height ($craneHeight / 2.5)
left 47%
bottom 10%
&:after
bottom 0
width 40%
height 85%
left 20%
.crane, .buildings
position absolute
bottom 0
.crane div
border-radius 2px
position absolute
.crane .line
border none
background $cityColor
outline 1px solid transparent
z-index 0
.crane .lineOne
width 60%
left 11%
top 0
.crane .lineTwo
width 19%
right 8%
top 0
.crane .line.lineThree
height 30%
top 22%
left 9%
&:after
content ''
position absolute
height .2em
width 9000%
background lighten($cityColor, 20%)
display block
bottom 0
left -4500%
border solid $craneBorder $cityColor
.craneTwo .line.lineThree:after
height .1em
.craneThree .line.lineThree:after
height .05em
.stand
height 100%
width 5%
right 25%
z-index 1
background linear-gradient(to top, $cityColor, desaturate(lighten($cityColor, 30%), 20%))
.craneTwo .stand
background linear-gradient(to top, $cityColor, desaturate(lighten($cityColor, 25%), 20%))
.craneThree .stand
background linear-gradient(to top, $cityColor, desaturate(lighten($cityColor, 20%), 20%))
.weight
height 20%
width 8%
right 4%
top 12%
z-index 2
background desaturate(lighten($cityColor, 25%), 10%)
.craneTwo .weight
background desaturate(lighten($cityColor, 20%), 10%)
.craneThree .weight
background desaturate(lighten($cityColor, 15%), 10%)
.cabin
height 9%
width 12%
right 24%
top 20%
z-index 2
background desaturate(lighten($cityColor, 25%), 10%)
&:after
content ''
position absolute
height 10%
width 100%
background white
display block
top 60%
left 0
.craneTwo .cabin
background desaturate(lighten($cityColor, 20%), 10%)
.craneThree .cabin
background desaturate(lighten($cityColor, 15%), 10%)
.arm
height 7%
width 100%
top 15%
z-index 3
background desaturate(lighten($cityColor, 25%), 10%)
.craneTwo .arm
background desaturate(lighten($cityColor, 20%), 10%)
.craneThree .arm
background desaturate(lighten($cityColor, 15%), 10%)
.crane div.arm
border-top-left-radius 10px
.brick
height 6%
width 9%
bottom 0
left 40%
background lighten($cityColor, 10%)
.brickTwo
left 48%
.brickThree
bottom 5.5%
left 44%
.craneOne
width $craneWidth
height $craneHeight
left 20%
div
border solid $craneBorder $cityColor
.line
height $craneBorder
.lineThree
width $craneBorder
.craneTwo
width ($craneWidth / 1.3)
height ($craneHeight / 1.3)
transform scaleX(-1)
left 40%
z-index -1
div
border solid 1px $cityColor
.line
height ($craneBorder / 1.3)
.lineThree
width ($craneBorder / 1.4)
animation-delay 3s
.cabin, .arm, .picker, .weight
animation-delay 3s
.craneThree
width ($craneWidth / 2)
height ($craneHeight / 2)
left 60%
z-index -1
div
border solid 1px $cityColor
.line
height ($craneBorder / 2)
.lineThree
width ($craneBorder / 2)
animation-delay 1.5s
.brickThree
bottom 5%
.brickOne, .brickTwo
bottom 0
.cabin, .arm, .picker, .weight
animation-delay 1.5s
.crane
perspective 600px
.lineOne
transform-origin right 0
animation moveLineOne 12s infinite alternate
.lineTwo
transform-origin top left
animation moveLineTwo 12s infinite alternate
.lineThree
transform-origin right center
animation moveLineThree 12s ease-in-out infinite alternate
.cabin, .arm, .picker
transform-origin 80% center
animation moveCrane 12s infinite alternate
.weight
transform-origin 0 center
animation moveWeight 12s infinite alternate
@keyframes moveCrane
0%, 20%
transform rotateY(0)
70%, 100%
transform rotateY(45deg)
@keyframes moveWeight
0%, 20%
transform rotateY(0) translateX(0)
70%, 100%
transform rotateY(45deg) translateX(-50%)
@keyframes moveLineOne
0%, 20%
transform rotateY(0) rotateZ(-10deg)
70%, 100%
transform rotateY(45deg) rotateZ(-10deg)
@keyframes moveLineTwo
0%, 20%
transform rotateY(0) rotateZ(29deg)
70%, 100%
transform rotateY(15deg) rotateZ(29deg)
@keyframes moveLineThree
0%
transform translate(0, 0)
20%
transform translate(2500%, -18%)
60%
transform translate(11000%, -25%)
70%
transform translate(9100%, -25%)
height 30%
90%, 100%
transform translate(9100%, -15%)
height 80%
html
-ms-text-size-adjust 100%
-webkit-text-size-adjust 100%
-webkit-tap-highlight-color transparent
html, body
height 100%
*
box-sizing border-box
body
background linear-gradient(to top, lighten($cityColor, 40%), hue($cityColor, 40%))
-webkit-font-smoothing antialiased
-moz-osx-font-smoothing grayscale
text-shadow 1px 1px 1px rgba(0,0,0,0.004)
#content
height 100%
width 100%
display flex
flex-direction column
align-items center
justify-content center
font-family Ubuntu
color white
h1, p
margin -8rem 0 0 1rem
p
margin-top .5rem
#license
position absolute
bottom 0
right 5px
Also see: Tab Triggers