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.
mixin cuboid()
.cuboid(class!=attributes.class)
- let s = 0
while s < 6
.cuboid__side
- s++
.wardrobe
.wardrobe__rail
+cuboid()(class="rail")
.wardrobe__shelf
.cuboid.shelf
.cuboid__side
.cuboid__side
.cuboid__side
.cuboid__side
.cuboid__side.css
span CSS
.cuboid__side
.wardrobe__panel.wardrobe__panel--top
+cuboid()(class="panel-cuboid panel-cuboid--top")
.wardrobe__panel.wardrobe__panel--right
.cuboid.panel-cuboid.panel-cuboid--right
.cuboid__side
.cuboid__side
.cuboid__side
.cuboid__side
.cuboid__side
.cuboid__side.is
span is
.wardrobe__panel.wardrobe__panel--bottom
.wardrobe__leg.wardrobe__leg--ne
+cuboid(class="leg")
.wardrobe__leg.wardrobe__leg--nw
+cuboid(class="leg")
.wardrobe__leg.wardrobe__leg--se
+cuboid(class="leg")
.wardrobe__leg.wardrobe__leg--sw
+cuboid(class="leg")
+cuboid()(class="panel-cuboid panel-cuboid--bottom")
.wardrobe__panel.wardrobe__panel--left
+cuboid()(class="panel-cuboid panel-cuboid--left")
.wardrobe__panel.wardrobe__panel--front
.wardrobe__door.wardrobe__door--left
details
summary
.door.door--left
+cuboid()(class="door-cuboid door-cuboid--left")
.wardrobe__door.wardrobe__door--right
details
summary
.door.door--right
.cuboid.door-cuboid.door-cuboid--right
.cuboid__side
.cuboid__side
.cuboid__side
.cuboid__side
.cuboid__side
.cuboid__side
.awesome
- for (const letter of 'Awesome'.split(''))
span= letter
img(src="https://assets.codepen.io/605876/avatar.png")
.wardrobe__panel.wardrobe__panel--back
*
*:after
*:before
box-sizing border-box
transform-style preserve-3d
@property --spin
initial-value 0deg
inherits false
syntax '<angle>'
:root
--bg hsl(120, 30%, 80%)
--width 30
--height 54
--backboard hsl(45, 40%, 70%)
--depth 20
--rx -20
--ry 38
--thickness 1
--hue 0
--saturation 0%
--unit-one 'hsl(%s, %s, 60%)' % (var(--hue) var(--saturation))
--unit-two 'hsl(%s, %s, 50%)' % (var(--hue) var(--saturation))
--unit-three 'hsl(%s, %s, 40%)' % (var(--hue) var(--saturation))
--unit-four 'hsl(%s, %s, 30%)' % (var(--hue) var(--saturation))
--shelf-one hsl(0, 0%, 90%)
--shelf-two hsl(0, 0%, 85%)
--shelf-three hsl(0, 0%, 80%)
--rail-one hsl(0, 0%, 90%)
--rail-two hsl(0, 0%, 80%)
--rail-three hsl(0, 0%, 100%)
--handle hsl(0, 0%, 90%)
--open 0
body
font-weight bold
font-family sans-serif
// Cuboid utility class
.cuboid
width 100%
height 100%
position relative
// 1 is the top and go t, r, b, l, f, b
&__side:nth-of-type(1)
height calc(var(--thickness) * 1vmin)
width 100%
position absolute
top 0
transform translate(0, -50%) rotateX(90deg)
&__side:nth-of-type(2)
height 100%
width calc(var(--thickness) * 1vmin)
position absolute
top 50%
right 0
transform translate(50%, -50%) rotateY(90deg)
&__side:nth-of-type(3)
width 100%
height calc(var(--thickness) * 1vmin)
position absolute
bottom 0
transform translate(0%, 50%) rotateX(90deg)
&__side:nth-of-type(4)
height 100%
width calc(var(--thickness) * 1vmin)
position absolute
left 0
top 50%
transform translate(-50%, -50%) rotateY(90deg)
&__side:nth-of-type(5)
height 100%
width 100%
transform translate3d(0, 0, calc(var(--thickness) * 0.5vmin))
position absolute
top 0
left 0
&__side:nth-of-type(6)
height 100%
width 100%
transform translate3d(0, 0, calc(var(--thickness) * -0.5vmin)) rotateY(180deg)
position absolute
top 0
left 0
body
background-color var(--bg)
min-height 100vh
display grid
place-items center
.wardrobe
animation spin 10s infinite linear
height calc(var(--height) * 1vmin)
width calc(var(--width) * 1vmin)
transform translate3d(-50%, -50%, 50vmin) rotateX(calc(var(--rx) * 1deg)) rotateY(calc(var(--ry) * 1deg))
// transform translate3d(-50%, -50%, 50vmin) rotateX(calc(var(--rx) * 1deg)) rotateY(var(--spin))
position absolute
top 50%
left 50%
// @keyframes spin
// to
// --spin 360deg
&__panel
position absolute
&--top
&--bottom
height calc(var(--depth) * 1vmin)
width calc((var(--width) + 1) * 1vmin)
left 50%
transform translate(-50%, calc(50% * var(--coefficient))) rotateX(90deg)
&--top
--coefficient -1
top 0
&--bottom
--coefficient 1
bottom 4%
&--left
&--right
height calc(100% - 4% - 1vmin)
width calc(var(--depth) * 1vmin)
top 0.5vmin
transform translate(calc(50% * var(--coefficient)), 0) rotateY(calc(90deg * var(--coefficient)))
&--left
--coefficient -1
left 0
&--right
--coefficient 1
right 0
&--back
&--front
height 96%
width calc(var(--width) * 1vmin)
transform translate3d(0, 0, calc((var(--coefficient) * var(--depth)) * 1vmin))
&--back
--coefficient -0.5
background var(--backboard)
transform translate3d(0, 0, calc(((var(--coefficient) * var(--depth)) * 1vmin) - 1px))
&--front
--coefficient 0.5
display flex
&__leg
--size calc(var(--depth) * 0.2vmin)
height var(--size)
width var(--size)
position absolute
transform translate3d(0, 0, calc((var(--height) * 0.02) * -1vmin))
--thickness calc(var(--height) * 0.04)
&--ne
top 1px
left 1px
&--nw
top 1px
right 1px
&--se
bottom 1px
left 1px
&--sw
bottom 1px
right 1px
&__rail
height calc(var(--thickness) * 1vmin)
width 100%
top 15%
position absolute
&__shelf
height calc(var(--depth) * 0.75vmin)
width 100%
top 65%
position absolute
transform rotateX(90deg) translate(0, (calc(var(--depth) * -0.12vmin)))
&__door
position absolute
width calc(50% + 0.5vmin)
height calc(100% + 0.5vmin)
top -0.25vmin
&--left
left -0.5vmin
--origin 0 50%
--coefficient -1
&--right
right -0.5vmin
--origin 100% 50%
--coefficient 1
details
position relative
height 100%
width 100%
z-index 2
transform translate3d(0, 0, 0.5vmin)
&:hover:not([open]) ~.door
--open 0.05
summary
height 100%
position absolute
top 0
left 0
z-index 2
width 100%
cursor pointer
opacity 1
outline transparent
&::-webkit-details-marker
display none
&:after
content ''
position absolute
top 0
left 0
height 100%
width 100%
transform-origin var(--origin)
transition transform 0.2s
transform rotateY(calc((var(--open) * (115 * var(--coefficient))) * 1deg)) translate3d(0, 0, 0.5vmin)
[open]
[open] ~ .door
--open 1
.door
height 100%
width 100%
position absolute
pointer-events none
top 0
left 0
transition transform 0.2s
transform rotateY(calc((var(--open) * (120 * var(--coefficient))) * 1deg))
transform-origin var(--origin)
.door-cuboid
transform translate3d(0, 0, 0.5vmin)
.rail
div
background var(--rail-one)
&:nth-of-type(1)
background var(--rail-two)
&:nth-of-type(4)
background var(--rail-three)
&:nth-of-type(5)
background var(--rail-one)
.shelf
div
background var(--shelf-one)
&:nth-of-type(3)
background var(--shelf-two)
&:nth-of-type(4)
background var(--shelf-three)
&:nth-of-type(5)
background var(--shelf-one)
.leg
.door-cuboid
.panel-cuboid
& > div
background var(--unit-one)
&:nth-of-type(3)
background var(--unit-one)
&:nth-of-type(4)
background var(--unit-three)
&:nth-of-type(5)
background var(--unit-two)
.door-cuboid
& > div
&:nth-of-type(1)
background var(--unit-four)
.panel-cuboid
&--bottom
div
&:nth-of-type(5)
background var(--unit-three)
&--left
div
&:nth-of-type(5)
background var(--unit-three)
&--right
div
&:nth-of-type(6)
background var(--unit-four)
.door-cuboid
div:nth-of-type(5):after
content ''
height 24%
width 8%
background var(--handle)
position absolute
top 50%
right 5%
transform translate(0, -50%)
&--left
div
&:nth-of-type(5):after
right 5%
&--right
div
&:nth-of-type(5):after
left 5%
&:nth-of-type(6)
background var(--unit-one)
img
position absolute
height 8%
transform rotate(34deg)
bottom 5%
left 10%
filter saturate(0.5)
.css
display grid
place-items center
font-size 6vmin
color hsl(0, 0%, 10%)
span
display block
text-align right
width 100%
padding-right 10%
.is
display grid
place-items center
font-size 6vmin
color hsl(0, 0%, 98%)
padding-top 70%
.awesome
font-size 5vmin
position absolute
display flex
flex-direction column
align-items center
top 50%
left 50%
transform translate(-50%, -55%)
span
animation sway 1s calc(var(--index) * -0.1s) infinite ease-in-out
color 'hsl(%s, 80%, 100%)' % var(--hue, 0)
text-transform uppercase
&:nth-of-type(1)
--index 0
--hue 15
&:nth-of-type(2)
--index 1
--hue 35
&:nth-of-type(3)
--index 2
--hue 50
&:nth-of-type(4)
--index 3
--hue 90
&:nth-of-type(5)
--index 4
--hue 180
&:nth-of-type(6)
--index 5
--hue 280
&:nth-of-type(7)
--index 6
--hue 320
@keyframes sway
0%, 100%
transform translate(-25%, 0)
50%
transform translate(25%, 0)
Also see: Tab Triggers