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.
.envelope
input.envelope__check(type='checkbox')
.envelope__flap.envelope__flap--inside
.envelope__flap
.envelope__letter
.letter
.letter__content
p Hey! 👋
p.
The whole purpose of places like Starbucks is for people with no decision-making ability whatsoever to make six decisions just to buy one cup of coffee. Short, tall, light, dark, caf, decaf, low-fat, non-fat, etc. 😕
.letter__content
.letter__content
p.
So people who don't know what the hell they're doing or who on earth they are can, for only $2.95, get not just a cup of coffee but an absolutely defining sense of self: Tall. Decaf. Cappuccino. ☕️
span.sign-off Joe Fox
.envelope__back
*
box-sizing border-box
body
background-color #111
text-align center
height 100vh
width 100vw
display flex
align-items center
justify-content center
overflow hidden
margin 0
padding 0
font-family 'Arial', sans-serif
font-size 12px
$flapTransition = 0.25s
$contentTransition = .25s
$foldTransition = .25s
$envelopeColor = #cebda6
$patternGap = 10px
$borderWhite = $envelopeColor
$borderRed = #e74c3c
$borderBlue = dodgerblue
.envelope
width 300px
height 150px
background darken($envelopeColor, 20%)
position relative
&__check
height 100%
width 100%
z-index 10
opacity 0
position absolute
left 0
top 0
margin 0
cursor pointer
&:checked
& ~ .envelope__flap
transition transform $flapTransition 0s, z-index 0s $flapTransition
transform rotateX(-180deg)
z-index 0
& ~ .envelope__letter
transform translateY(-110%)
transition transform $contentTransition $flapTransition, z-index 0s ($flapTransition +$contentTransition)
z-index 5
.letter__content:nth-child(2)
.letter__content:nth-child(3)
transition transform $foldTransition ($flapTransition + $contentTransition)
transform rotateX(0deg)
&__flap
$borderWhite = darken($envelopeColor, 10%)
position absolute
top 0
left 0
right 0
height 75%
transition transform $flapTransition ($contentTransition + $foldTransition), z-index 0s ($contentTransition + $foldTransition)
transform-origin top center
backface-visibility hidden
background repeating-linear-gradient(-45deg, $borderWhite, $borderWhite $patternGap, $borderRed $patternGap, $borderRed ($patternGap * 2px), $borderWhite ($patternGap * 2px), $borderWhite ($patternGap * 3px), $borderBlue ($patternGap * 3px), $borderBlue ($patternGap * 4px)) 0 0 / 100% 5px no-repeat,
darken($envelopeColor, 10%)
z-index 4
// clip-path polygon(5% 40%, 30% 100%, 70% 100%, 95% 40%, 100% 0, 0 0)
clip-path polygon(5% 40%, 50% 100%, 95% 40%, 100% 0, 0 0)
&--inside
background darken($envelopeColor, 10%)
backface-visibility visible
&__back
height 100%
width 100%
height 100%
width 100%
position absolute
top 0
left 0
z-index 3
background repeating-linear-gradient(-45deg, $borderWhite, $borderWhite $patternGap, $borderRed $patternGap, $borderRed ($patternGap * 2px), $borderWhite ($patternGap * 2px), $borderWhite ($patternGap * 3px), $borderBlue ($patternGap * 3px), $borderBlue ($patternGap * 4px)) 0 100% / 100% 5px no-repeat,
repeating-linear-gradient(-45deg, $borderWhite, $borderWhite $patternGap, $borderRed $patternGap, $borderRed ($patternGap * 2px), $borderWhite ($patternGap * 2px), $borderWhite ($patternGap * 3px), $borderBlue ($patternGap * 3px), $borderBlue ($patternGap * 4px)) 0 100% / 5px 100% no-repeat,
repeating-linear-gradient(-45deg, $borderWhite, $borderWhite $patternGap, $borderRed $patternGap, $borderRed ($patternGap * 2px), $borderWhite ($patternGap * 2px), $borderWhite ($patternGap * 3px), $borderBlue ($patternGap * 3px), $borderBlue ($patternGap * 4px)) 100% 100% / 5px 100% no-repeat,
$envelopeColor
clip-path polygon(80% 40%, 100% 0, 100% 100%, 0 100%, 0 0, 20% 40%)
&:after
$borderWhite = darken($envelopeColor, 5%)
height 100%
width 100%
background repeating-linear-gradient(-45deg, $borderWhite, $borderWhite $patternGap, $borderRed $patternGap, $borderRed ($patternGap * 2px), $borderWhite ($patternGap * 2px), $borderWhite ($patternGap * 3px), $borderBlue ($patternGap * 3px), $borderBlue ($patternGap * 4px)) 0 100% / 100% 5px no-repeat,
darken($envelopeColor, 5%)
content ''
position absolute
top 0
left 0
clip-path polygon(70% 10%, 100% 100%, 0 100%, 30% 10%)
&__letter
height 90%
width 90%
z-index 1
position absolute
left 5%
top 5%
transition transform $contentTransition $foldTransition, z-index 0s $foldTransition
transform translateY(0)
.letter
&__content
height 100%
width 100%
background-color white
top 0
left 0
position absolute
padding 14px
text-align justify
&:nth-child(2)
&:nth-child(3)
transition transform $foldTransition
top 100%
transform-origin top center
transform rotateX(180deg)
backface-visibility visible
z-index 2
border-top 1px solid #eee
&:nth-child(3)
backface-visibility hidden
.sign-off
position absolute
bottom 12px
right 12px
font-size 20px
font-family cursive
transform skewX(-20deg)
Also see: Tab Triggers