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.
<body>
<div id="container"></div>
<script id="template">
<div class="flip-card" on-click="toggle('flipCard')">{{ flipCard ? 'Reset' : 'Animate' }}</div>
<div class="contact-wrapper">
<div class="envelope {{ flipCard ? 'active' : '' }}">
<div class="back paper"></div>
<div class="content">
<div class="form-wrapper">
<form>
<div class="top-wrapper">
<div class="input">
<label>Name</label>
<input type="text" name="name"/>
</div>
<div class="input">
<label>Phone</label>
<input type="text" name="phone"/>
</div>
<div class="input">
<label>Email</label>
<input type="text" name="_replyto"/>
</div>
</div>
<div class="bottom-wrapper">
<div class="input">
<label>Subject</label>
<input type="text" name="_subject"/>
</div>
<div class="input">
<label>Message</label>
<textarea rows="5" name="message"></textarea>
</div>
<div class="submit">
<div class="submit-card" on-click="toggle('flipCard')">Send Mail</div>
</div>
</div>
</form>
</div>
</div>
<div class="front paper"></div>
</div>
</div>
</script>
</body>
body
background linear-gradient(45deg, #BB1881, #F88B50)
font-family sans-serif
.contact-wrapper
position absolute
top 50%
transform translateY(-50%)
width 100%
.flip-card
border-radius 0.5em
position fixed
top 1em
left 1em
width 5em
padding 0.5em
border 0.1em solid #fff
color #fff
text-align center
cursor pointer
z-index 9
.envelope
position relative
display block
width 30em
height 35em
margin 0 auto
&.active
.content
padding 15em 2em 2em
.paper.front,
.paper.back
animation-duration 1.5s
animation-direction normal
animation-timing-function ease-in-out
animation-fill-mode forwards
.paper.front
animation-name envelope-front
.paper.back
animation-name envelope-back
&:before
animation-duration 0.5s
animation-direction normal
animation-timing-function ease-in-out
animation-fill-mode forwards
animation-delay 1.25s
animation-name envelope-back-before
.bottom-wrapper
transform rotateX(180deg)
&:after
z-index 0
opacity 1
.content
padding 2em
box-sizing border-box
position relative
z-index 9
transition all 0.5s ease-in-out
transition-delay 1s
.top-wrapper,
.bottom-wrapper
box-sizing border-box
background #03A9F5
color #fff
.top-wrapper
padding 2em 2em 0
border-top-left-radius 0.5em
border-top-right-radius 0.5em
.bottom-wrapper
padding 0 2em 2em
border-bottom-left-radius 0.5em
border-bottom-right-radius 0.5em
transition all 0.5s ease-in-out
transform-origin top
transform-style preserve-3d
position relative
overflow hidden
margin-top -1px
&:after
position absolute
content ''
display block
opacity 0
background #03A9F5
top 0
left 0
width 100%
height 100%
z-index -1
form
label
display block
padding-bottom 0.5em
input,
textarea
width 100%
box-shadow 0
background transparent
color #fff
input
border-width 0 0 0.1em
border-color #fff
border-style solid
textarea
border 0.1em solid #fff
border-radius 0.25em
.submit-card
background #fff
color #222
text-align center
padding 0.5em
box-sizing border-box
background #fff
width 100%
border 0
box-shadow none
border-radius 0.25em
cursor pointer
.input
padding-bottom 1em
.paper
position absolute
display block
top 0
left 0
border-bottom-left-radius 0.5em
border-bottom-right-radius 0.5em
overflow hidden
&.back
top 0
&:before
content ''
display block
width 0
height 0
margin-bottom -1px
border-style solid
border-width 0 15em 10em 15em
border-color transparent transparent #d3d3d3 transparent
transform-origin bottom
transform-style preserve-3d
z-index 0
&:after
content ''
display block
background-color #d3d3d3
width 30em
height 20em
&.front
top 10em
box-shadow 0.1em 0.5em 0.5em rgba(0,0,0,0.25)
z-index 0
&:before
content ''
display block
width 0
height 0
border-style solid
border-width 10em 15em 0 15em
border-color transparent #fff
&:after
content ''
display block
width 30em
height 10em
background #fff
margin-top -1px
@keyframes envelope-front {
0 {
top: 10em;
z-index: 0;
}
50% {
top: 15em;
z-index: 9;
}
100% {
top: 10em;
z-index: 9;
}
}
@keyframes envelope-back {
0 {
top: 0;
}
50% {
top: 5em;
}
100% {
top: 0;
}
}
@keyframes envelope-back-before {
0 {
border-color transparent transparent #d3d3d3 transparent
transform: rotateX(0deg);
z-index: 0;
}
100% {
border-color transparent transparent #fff transparent
transform: rotateX(180deg);
z-index: 99;
position: relative;
}
}
var ractive = new Ractive({
el: '#container',
template: '#template',
data: {}
});
Also see: Tab Triggers