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.
<div class="contact">
<div class="wrapper">
<p class="close">Close <i class="fa fa-times-circle"></i></p>
<p>Name:<br />
<input type="text" /></p>
<p>Email:<br />
<input type="email" /></p>
<p>Subject:<br />
<input type="text" /></p>
<p>Message:<br />
<textarea></textarea></p>
<p><input id="submit" type="submit" value="Send" /></p>
<p class="thanks">Thank you, we'll be in touch soon.</p>
</div>
</div>
<div class="topbar">
<div class="wrapper">
My Site <span id="open-form" class="open">Contact <i class="fa fa-envelope"></i></span>
</div>
</div>
<div class="wrapper page">
<h1><i class="fa fa-pencil"></i> Drop-Down Contact Form</h1>
<p>Thank you message and close on submit.</p>
<p>Aenean at nisi ligula! Sed gravida nisi at dolor ullamcorper lacinia. Vivamus semper justo in augue sagittis, condimentum feugiat sem placerat. Donec tincidunt sapien sed congue venenatis. In laoreet dictum eros, euismod sagittis urna cursus at? Fusce ut accumsan ante. Morbi placerat dui lorem, ac tincidunt ligula blandit quis. Vivamus accumsan tincidunt nibh eget eleifend. Cras risus libero, luctus nec ultricies eu, molestie a tortor. Nullam molestie pharetra mi, sit amet accumsan enim luctus quis. Pellentesque metus est, eleifend non iaculis et, varius in enim.</p>
<p>Curabitur consequat neque id mollis tristique. Nunc efficitur tellus at metus malesuada pellentesque. Ut et venenatis leo! Quisque vel diam bibendum, semper risus eu, pharetra erat. Fusce id libero elementum, consectetur orci eget; rhoncus est. Sed et mattis diam. Proin aliquam tincidunt diam, et sodales dolor ullamcorper et. Sed in est pretium, sodales dui id, auctor ligula. Duis posuere, urna non fermentum consectetur, erat lacus tempus dolor, a feugiat nisi nisl ac elit? Sed sit amet enim non ipsum malesuada gravida! Duis ullamcorper ornare ligula vestibulum malesuada. Donec quis nisl sed turpis blandit consectetur. Nullam dictum purus vitae mattis tincidunt!</p>
<p>Integer ut orci dignissim, elementum dui quis, blandit leo. Curabitur ultrices nisl ac ullamcorper tempus. Vivamus accumsan tincidunt felis sed vulputate. Sed cursus purus quis lectus interdum tincidunt. Duis tristique fringilla consequat. Phasellus auctor cursus felis, ut volutpat tellus tincidunt in. Nunc vulputate molestie neque, sit amet facilisis velit efficitur vitae. Mauris magna est, cursus nec mi a, placerat venenatis ante. Nam in feugiat neque. Praesent condimentum ex at purus luctus porta. Vivamus consectetur posuere leo at auctor. Vestibulum sed rutrum est, sit amet convallis libero! Fusce consectetur blandit ex, sit amet eleifend lectus tempus et. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
<p>Morbi pharetra metus vel euismod ultricies. Maecenas pretium arcu ut enim porta bibendum. Etiam lacus libero, mollis quis tortor eu, hendrerit semper diam. Suspendisse sed dolor sed metus porta scelerisque eget quis enim. Suspendisse potenti. Pellentesque at sollicitudin nulla. Morbi finibus urna risus. Nullam commodo auctor dui eu pulvinar. Vivamus tincidunt; nisi ut sodales pretium, ipsum magna cursus dui, a feugiat ipsum mi id massa.</p>
<p>Quisque tellus ligula, porttitor in velit quis, porttitor dignissim risus. Nam aliquam gravida massa, sit amet auctor augue faucibus nec! Suspendisse et augue posuere; tincidunt magna sed, iaculis lorem. Sed non maximus elit, non vulputate justo. Nam erat diam, egestas vel laoreet eget; euismod quis tortor. Etiam vel felis fringilla, tincidunt sapien eu, scelerisque dolor. Pellentesque sit amet tortor quis sapien hendrerit vestibulum? Etiam mollis ullamcorper scelerisque.</p>
</div>
body {
position: relative;
background: #f0eace;
color: #4b3b35;
font-family: 'Open Sans', arial, sans-serif;
font-size: 1.4em;
line-height: 1.4em;
}
h1 {
font-family: 'Patua One', serif;
font-size: 2em;
margin-bottom: .8em;
}
.fa {z-index: 10;}
p {margin-bottom: 1.2em;}
.wrapper {
max-width: 1024px;
margin: 0 auto;
padding: 0 1em;
&.page {padding: 4em 1em;
p:first-of-type {font-weight: 700;}
}
}
.contact {
position: absolute;
z-index: 20;
top: 60px;
left: 0;
right: 0;
padding: 2em;
background: #5d5550;
color: #ede6bd;
transition: all .4s;
transform: translateY(-100%);
&.open-form {
transform: translateY(0);
}
p {font-weight: 600;
&.close {
text-align: right;
cursor: pointer;
}
&.thanks {
opacity: 0;
transition: opacity .2s;
}
&.thanks.visible {opacity: 1;}
}
input, textarea {
width: 100%;
background: #f0edde;
border: #4b3b35 solid 2px;
border-radius: .5em;
resize: none;
padding: .7em 1em;
color: #5d5550;
font-family: 'Open Sans', arial, sans-serif;
font-size: .65em;
font-weight: 600;
}
textarea {
font-size: .6em;
height: 20em;
}
input[type="submit"] {
width: auto;
font-size: .8em;
font-weight: 900;
cursor: pointer;
}
}
.topbar {
z-index: 30;
position: fixed;
top: 0;
width: 100%;
background: #4b3b35;
color: #ede6bd;
font-weight: 900;
height: 60px;
line-height: 60px;
span {
float: right;
font-weight: 600;
&.open {cursor: pointer;}
}
}
$(function() {
$("#open-form").click(function(){
$(".contact").addClass("open-form");
});
});
$(function() {
$("#submit").click(function(){
setTimeout('jQuery(".contact").removeClass("open-form")', 3000);
setTimeout('jQuery(".thanks").removeClass("visible")', 3000);
});
});
$(function() {
$("#submit").click(function(){
$(".thanks").addClass("visible");
});
});
$(function() {
$(".close").click(function(){
$(".contact").removeClass("open-form");
});
});
Also see: Tab Triggers