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++
mixin nft()
.nft
.nft__rim
.nft__rim-segment
+cuboid()(class="rim-segment rim-segment--one")
.nft__rim-segment
+cuboid()(class="rim-segment rim-segment--two")
.nft__rim-segment
+cuboid()(class="rim-segment rim-segment--three")
.nft__rim-segment
+cuboid()(class="rim-segment rim-segment--four")
.nft__rim-segment
+cuboid()(class="rim-segment rim-segment--five")
.nft__rim-segment
+cuboid()(class="rim-segment rim-segment--six")
.nft__n
.nft__n-segment
+cuboid()(class="n-segment n-segment--one")
.nft__n-segment
+cuboid()(class="n-segment n-segment--two")
.nft__n-segment
+cuboid()(class="n-segment n-segment--three")
.nft__f
.nft__f-segment
+cuboid()(class="f-segment f-segment--one")
.nft__f-segment
+cuboid()(class="f-segment f-segment--two")
.nft__f-segment
+cuboid()(class="f-segment f-segment--three")
.nft__f-segment
+cuboid()(class="f-segment f-segment--four")
.nft__t
.nft__t-segment
+cuboid()(class="t-segment t-segment--one")
.nft__t-segment
+cuboid()(class="t-segment t-segment--two")
.scene__wrapper
.scene
+nft()
.scene__wrapper--reflection
.scene
//- +nft()
.nft__reflection
+nft()
img(src="https://assets.codepen.io/605876/avatar.png")
*
*:after
*:before
box-sizing border-box
transform-style preserve-3d
:root
--size 50vmin
--shade-one hsl(192, 95%, 56%)
--shade-two hsl(192, 78%, 52%)
--shade-three hsl(192, 73%, 47%)
--shade-four hsl(192, 74%, 42%)
--shade-five hsl(192, 74%, 37%)
--shade-six hsl(192, 73%, 32%)
--shade-seven hsl(192, 73%, 28%)
--shade-eight hsl(192, 74%, 23%)
body
min-height 100vh
display grid
place-items center
background hsl(0, 0%, 6%)
.scene
position fixed
height var(--size)
width var(--size)
top 50%
left 50%
transform translate3d(-50%, -50%, -50vmin) rotateX(-24deg) rotateY(32deg) rotateX(90deg) rotateZ(0deg)
animation rotate 5s infinite linear
.scene__wrapper
filter drop-shadow(0 0 1vmin var(--shade-one)) brightness(1.05)
position fixed
height 100vh
width 100vw
&--reflection
filter drop-shadow(0 0 1vmin var(--shade-one)) blur(25px)
@keyframes rotate
to
transform translate3d(-50%, -50%, -50vmin) rotateX(-24deg) rotateY(32deg) rotateX(90deg) rotateZ(-360deg)
img
position fixed
bottom 1rem
right 1rem
height 5vmin
.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
.nft
height 100%
width 100%
position absolute
top 50%
left 50%
transform translate(-50%, -50%) rotateY(calc(var(--rotateY, 0) * 1deg)) rotateX(calc(var(--rotateX, 0) * 1deg)) rotateX(-90deg)
&__reflection
height 100%
width 100%
position absolute
top 50%
left 50%
transform-origin 50% 50%
transform translate(-50%, -50%) rotateY(180deg) rotateZ(180deg) translate3d(0%, 0%, calc(var(--size) * 1.05))
&__rim
height 100%
width 86%
position absolute
top 50%
left 50%
transform translate(-50%, -50%)
&-segment
height 50%
width 6%
position absolute
&:nth-of-type(1)
top 25%
left -0.45%
width 6.5%
&:nth-of-type(2)
top 25%
right -0.45%
width 6.5%
&:nth-of-type(3)
top 0%
left 50%
transform translate(0%, 0%) rotate(60deg)
transform-origin 0 0
&:nth-of-type(4)
top 0%
right 50%
transform translate(0%, 0%) rotate(-60deg)
transform-origin 100% 0
&:nth-of-type(5)
bottom 0%
left 50%
transform translate(0%, 0%) rotate(-60deg)
transform-origin 0% 100%
&:nth-of-type(6)
bottom 0%
right 50%
transform translate(0%, 0%) rotate(60deg)
transform-origin 100% 100%
&__n
height 56.5%
width 16.5%
position absolute
top 22.5%
left 16.5%
&-segment
position absolute
&:nth-of-type(1)
top 14%
height 74%
width 30%
&:nth-of-type(2)
top 14%
right 70%
height 80.25%
width 32%
transform-origin 100% 0
transform rotate(-14.65deg)
&:nth-of-type(3)
top 0%
right 0
height 100%
width 32%
&__f
left 50%
position absolute
top 11%
width 32%
height 74%
transform translate(-50%, 0%)
&-segment
position absolute
&:nth-of-type(1)
left 11%
top 11%
height 89%
width 16%
&:nth-of-type(2)
left 26%
top 48.5%
height 8.5%
width 60%
&:nth-of-type(3)
left 50%
top 0%
height 8%
width 58%
transform-origin 0 0
transform rotate(32deg)
&:nth-of-type(4)
right 50%
top 0%
height 8%
width 46.5%
transform-origin 100% 0
transform rotate(-33deg)
&__t
position absolute
top 22%
left 65.5%
height 55%
width 20%
&-segment
position absolute
&:nth-of-type(1)
width 130%
top 10%
left 50%
height 10%
transform translate(-50%, 0%) rotate(32deg)
&:nth-of-type(2)
width 28%
top 13%
left 50%
height 87%
transform translate(-50%, 0%)
// Cuboid styling
.t-segment
--thickness 4
.t-segment--one
left 11%
width 90%
div
background var(--shade-two)
&:nth-of-type(2)
background transparent
&:after
content ''
position absolute
height 118%
bottom 0
width 100%
transform-origin 50% 100%
transform rotateX(32deg)
background var(--shade-eight)
&:nth-of-type(3)
background var(--shade-six)
&:nth-of-type(4)
background var(--shade-three)
&:nth-of-type(1)
background transparent
&:after
content ''
height 100%
width 86%
position absolute
background var(--shade-six)
&:nth-of-type(5)
overflow hidden
background transparent
&:after
content ''
position absolute
height 600%
width 150%
right 14%
background var(--shade-two)
transform-origin 100% 0
transform rotate(-32deg) translate(0, -50%)
&:nth-of-type(6)
overflow hidden
background transparent
&:after
content ''
position absolute
height 600%
width 150%
left 14%
background var(--shade-two)
transform-origin 0% 0
transform rotate(32deg) translate(0, -50%)
.t-segment--two
div
background var(--shade-two)
&:nth-of-type(3)
background transparent
&:after
content ''
position absolute
height 100%
width 118%
background var(--shade-six)
transform-origin 0 50%
transform rotateY(-31deg)
&:nth-of-type(4)
background var(--shade-one)
&:nth-of-type(2)
background linear-gradient(var(--shade-eight) 0 50%, transparent 50%)
&:after
content ''
height 93%
width 100%
background var(--shade-eight)
position absolute
&:nth-of-type(5)
background linear-gradient(var(--shade-two) 0 50%, transparent 50%)
overflow hidden
&:after
content ''
height 93%
width 400%
left 0
bottom 0
background var(--shade-two)
position absolute
transform-origin 0 100%
transform rotate(-30deg)
&:nth-of-type(6)
background linear-gradient(var(--shade-two) 0 50%, transparent 50%)
overflow hidden
&:after
content ''
height 93%
width 400%
right 0
bottom 0
background var(--shade-two)
position absolute
transform-origin 100% 100%
transform rotate(30deg)
.f-segment
--thickness 4
.f-segment--one
div
&:nth-of-type(2)
background var(--shade-eight)
&:nth-of-type(3)
background transparent
&:after
content ''
position absolute
height 100%
width 118%
right 0
background var(--shade-six)
transform-origin 100% 50%
transform rotateY(30deg)
&:nth-of-type(4)
background transparent
&:after
content ''
height 95.5%
width 100%
background var(--shade-one)
position absolute
&:nth-of-type(5)
background linear-gradient(var(--shade-two) 0 80%, transparent 80%)
overflow hidden
&:after
content ''
height 93%
width 400%
right 0
bottom 0
background var(--shade-two)
position absolute
transform-origin 100% 100%
transform rotate(30deg)
&:nth-of-type(6)
background linear-gradient(var(--shade-two) 0 80%, transparent 80%)
overflow hidden
&:after
content ''
height 93%
width 400%
left 0
bottom 0
background var(--shade-two)
position absolute
transform-origin 0% 100%
transform rotate(-30deg)
.f-segment--two
div
background var(--shade-two)
&:nth-of-type(3)
background var(--shade-six)
&:nth-of-type(1)
background var(--shade-six)
&:nth-of-type(2)
background var(--shade-eight)
.f-segment--three
div
background var(--shade-two)
&:nth-of-type(2)
background var(--shade-eight)
&:nth-of-type(1)
&:nth-of-type(3)
background var(--shade-six)
.f-segment--four
div
background var(--shade-two)
&:nth-of-type(1)
background var(--shade-six)
&:nth-of-type(3)
background var(--shade-eight)
.n-segment
--thickness 4
.n-segment--one
div
background var(--shade-two)
&:nth-of-type(1)
background transparent
&:after
content ''
position absolute
top 0
right 0
height 100%
width 112%
background var(--shade-six)
transform-origin 100% 50%
transform rotateY(-28deg)
&:nth-of-type(2)
background var(--shade-eight)
&:nth-of-type(3)
background transparent
&:after
content ''
position absolute
top 0
right 0
height 100%
width 114%
background var(--shade-six)
transform-origin 100% 50%
transform rotateY(32deg)
&:nth-of-type(4)
background transparent
&:after
content ''
position absolute
top 6.15%
left 0
height 86.65%
width 100%
background var(--shade-one)
&:nth-of-type(5)
background linear-gradient(transparent 0 18%, var(--shade-two) 18% 82%, transparent 82%)
overflow hidden
&:before
content ''
position absolute
height 50%
width 200%
right 0
top 0
transform-origin 100% 0
transform rotate(-28deg)
background var(--shade-two)
&:after
content ''
position absolute
height 50%
width 200%
right 0
bottom 0
transform-origin 100% 100%
transform rotate(32deg)
background var(--shade-two)
&:nth-of-type(6)
background linear-gradient(transparent 0 18%, var(--shade-two) 18% 82%, transparent 82%)
overflow hidden
&:before
content ''
position absolute
height 50%
width 200%
left 0
top 0
transform-origin 0 0
transform rotate(28deg)
background var(--shade-two)
&:after
content ''
position absolute
height 50%
width 200%
left 0
bottom 0
transform-origin 0% 100%
transform rotate(-32deg)
background var(--shade-two)
.n-segment--three
div
background var(--shade-two)
&:nth-of-type(1)
background transparent
&:after
content ''
position absolute
top 0
right 0
height 100%
width 118%
background var(--shade-six)
transform-origin 100% 50%
transform rotateY(-32deg)
&:nth-of-type(2)
background var(--shade-eight)
&:nth-of-type(3)
background transparent
&:after
content ''
position absolute
top 0
right 0
height 100%
width 118%
background var(--shade-six)
transform-origin 100% 50%
transform rotateY(32deg)
&:nth-of-type(4)
background transparent
&:after
content ''
position absolute
top 6%
left 0
height 88%
width 100%
background var(--shade-one)
&:nth-of-type(5)
background linear-gradient(transparent 0 18%, var(--shade-two) 18% 82%, transparent 82%)
overflow hidden
&:before
content ''
position absolute
height 50%
width 200%
right 0
top 0
transform-origin 100% 0
transform rotate(-32deg)
background var(--shade-two)
&:after
content ''
position absolute
height 50%
width 200%
right 0
bottom 0
transform-origin 100% 100%
transform rotate(32deg)
background var(--shade-two)
&:nth-of-type(6)
background linear-gradient(transparent 0 18%, var(--shade-two) 18% 82%, transparent 82%)
overflow hidden
&:before
content ''
position absolute
height 50%
width 200%
left 0
top 0
transform-origin 0 0
transform rotate(32deg)
background var(--shade-two)
&:after
content ''
position absolute
height 50%
width 200%
left 0
bottom 0
transform-origin 0% 100%
transform rotate(-32deg)
background var(--shade-two)
.n-segment--two
--thickness 4
div
background var(--shade-two)
&:nth-of-type(4)
background transparent
&:after
content ''
position absolute
height 90%
bottom 0
left 0
width 100%
background var(--shade-one)
&:nth-of-type(1)
background transparent
&:after
content ''
position absolute
height 100%
width 105%
right 0
top 0
transform-origin 100% 50%
transform rotateY(-13deg)
background var(--shade-six)
&:nth-of-type(5)
background linear-gradient(transparent 0 10%, var(--shade-two) 10%)
overflow hidden
&:after
content ''
position absolute
height 50%
width 200%
right 0
top 0
transform-origin 100% 0%
transform rotate(-13deg)
background var(--shade-two)
&:nth-of-type(6)
background linear-gradient(transparent 0 10%, var(--shade-two) 10%)
overflow hidden
&:after
content ''
position absolute
height 50%
width 200%
left 0
top 0
transform-origin 0% 0%
transform rotate(13deg)
background var(--shade-two)
&:nth-of-type(2)
background var(--shade-eight)
.rim-segment
--thickness 4
.rim-segment--one
div
background-color var(--shade-two)
&:nth-of-type(4)
background-color var(--shade-one)
&:nth-of-type(2)
background-color var(--shade-eight)
.rim-segment--two
div
background-color var(--shade-two)
&:nth-of-type(4)
background-color var(--shade-one)
&:nth-of-type(2)
background-color var(--shade-eight)
.rim-segment--three
div
background-color var(--shade-two)
&:nth-of-type(4)
background-color var(--shade-one)
&:nth-of-type(2)
background-color var(--shade-eight)
.rim-segment--four
div
background-color var(--shade-two)
&:nth-of-type(4)
background-color var(--shade-one)
&:nth-of-type(2)
background-color var(--shade-eight)
.rim-segment--five
div
background-color var(--shade-two)
&:nth-of-type(4)
background-color var(--shade-one)
&:nth-of-type(2)
background-color var(--shade-eight)
.rim-segment--six
div
background-color var(--shade-two)
&:nth-of-type(4)
background-color var(--shade-one)
&:nth-of-type(2)
background-color var(--shade-eight)
Also see: Tab Triggers