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.
<link rel="stylesheet" href="//weloveiconfonts.com/api/?family=fontawesome" />
<span class="icon"></span>
<nav id="menu" class="off">
<div>
<a onclick="animatescroll('#home');" class="home-link active">
<span>Home</span>
</a>
<a onclick="animatescroll('#about');" class="about-link">
<span>About</span>
</a>
<a onclick="animatescroll('#portfolio');" class="portfolio-link">
<span>Portfolio</span>
</a>
<a onclick="animatescroll('#blog');" class="blog-link">
<span>Blog</span>
</a>
<a onclick="animatescroll('#contact');" class="contact-link">
<span>Contact</span>
</a>
</div>
</nav>
<section id="home">
<div class="container">
<h1>Home</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur atque repellendus aliquam modi numquam eius voluptatem unde eaque voluptas facere quisquam illo deserunt ratione fugiat nisi ea nemo sequi quo fugit ipsum quaerat optio sit vitae ducimus dolor totam temporibus. Minima quasi rem dolores quo voluptates doloribus illo? Adipisci itaque!</p>
</div>
</section>
<section id="about">
<div class="container">
<h1>About</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur atque repellendus aliquam modi numquam eius voluptatem unde eaque voluptas facere quisquam illo deserunt ratione fugiat nisi ea nemo sequi quo fugit ipsum quaerat optio sit vitae ducimus dolor totam temporibus. Minima quasi rem dolores quo voluptates doloribus illo? Adipisci itaque!</p>
<p>Minus voluptatem pariatur deleniti nesciunt reprehenderit provident corporis! Quisquam porro veniam dolore perspiciatis eos minus aperiam odio unde quod non ipsa explicabo ullam recusandae reprehenderit voluptatibus nobis velit repellat illo rerum omnis. Quisquam fugiat ad necessitatibus nulla soluta. Eligendi tenetur consequatur debitis odio quibusdam harum veniam dolorem voluptatibus repudiandae ipsum.</p>
</div>
</section>
<section id="portfolio">
<div class="container">
<h1>Portfolio</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur atque repellendus aliquam modi numquam eius voluptatem unde eaque voluptas facere quisquam illo deserunt ratione fugiat nisi ea nemo sequi quo fugit ipsum quaerat optio sit vitae ducimus dolor totam temporibus. Minima quasi rem dolores quo voluptates doloribus illo? Adipisci itaque!</p>
<p>Minus voluptatem pariatur deleniti nesciunt reprehenderit provident corporis! Quisquam porro veniam dolore perspiciatis eos minus aperiam odio unde quod non ipsa explicabo ullam recusandae reprehenderit voluptatibus nobis velit repellat illo rerum omnis. Quisquam fugiat ad necessitatibus nulla soluta. Eligendi tenetur consequatur debitis odio quibusdam harum veniam dolorem voluptatibus repudiandae ipsum.</p>
<p>Dolorem asperiores repudiandae iste voluptatibus laboriosam officiis soluta id nesciunt architecto eius cupiditate hic dolore voluptatum fugiat omnis saepe vel temporibus nobis magni unde. Aliquam animi eum nostrum eos nam fugiat ullam deserunt tempora laudantium odio nihil magni recusandae quis harum quasi sunt iusto perferendis corporis placeat et earum libero.</p>
</div>
</section>
<section id="blog">
<div class="container">
<h1>Blog</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur atque repellendus aliquam modi numquam eius voluptatem unde eaque voluptas facere quisquam illo deserunt ratione fugiat nisi ea nemo sequi quo fugit ipsum quaerat optio sit vitae ducimus dolor totam temporibus. Minima quasi rem dolores quo voluptates doloribus illo? Adipisci itaque!</p>
</div>
</section>
<section id="contact">
<div class="container">
<h1>Contact</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias deserunt.</p>
<form action="#">
<div>
<label for="name">Name</label>
<input type="text" placeholder="That One Guy" />
</div>
<div>
<label for="name">Email</label>
<input type="email" placeholder="sample@email.com" />
</div>
<div>
<label for="textarea">Message</label>
<textarea cols="40" rows="8" name="textarea" id="textarea" placeholder="What's up?"></textarea>
</div>
<div>
<input type="submit" value="Send" />
</div>
</form>
</div>
</section>
<footer>
<p>This has been a pen.</p>
</footer>
* { box-sizing: border-box; }
body {
font-family: 'Open Sans';
color: #fff;
font-size: 1.5em;
font-weight: 300;
}
.container {
width: 80%;
max-width: 600px;
margin: 0 auto;
}
h1 {
font-size: 2em;
margin: 0 0 1em;
}
h1:before {
font-family: 'FontAwesome';
color: #fff;
margin-right: .5em;
}
#home h1:before, .home-link:before { content: '\f015'; }
#about h1:before, .about-link:before { content: '\f075'; }
#portfolio h1:before, .portfolio-link:before { content: '\f0f2'; }
#blog h1:before, .blog-link:before { content: '\f09e'; }
#contact h1:before, .contact-link:before { content: '\f0e0'; }
p {
margin: 0 0 1em;
line-height: 1.25em;
text-align: justify;
}
/* -- Menu CSS -- */
#menu {
position: fixed;
top: 0; left: 0;
width: 0; height: 70px;
padding: 1em 3em;
overflow: hidden;
transition: all 0.5s;
}
#menu div { width: 9999px; }
.icon {
font-family: 'FontAwesome';
color: #fff;
font-size: 1.5em;
cursor: pointer;
display: block;
position: fixed;
top: 17px; left: 22px;
z-index: 21;
}
.icon:before { content: '\f0c9'; }
#menu a:before {
font-family: 'FontAwesome';
margin-right: .5em;
}
#menu.off a { display: none; }
#menu.on {
background: rgba(0,0,0,0.75);
width: 100%;
}
#menu.on a {
display: inline-block;
text-decoration: none;
margin: 0 1em;
padding: 0;
font-size: .75em;
color: #fff;
cursor: pointer;
}
#menu.on a:before { display: none; }
#menu.on a:hover, #menu.on a.active {
color: #888;
padding-bottom: 1px;
}
@media screen and (min-width: 43.75em) {
.icon { display: none; }
#menu {
width: auto; height: auto;
padding: 0;
background: 0;
top: 20px;
}
#menu a {
display: block;
width: 60px; height: 50px;
padding: .2em .5em;
cursor: pointer;
overflow: hidden;
background: rgba(0,0,0,.75);
}
#menu a:before { font-size: 1.5em; transition: color 0.2s; }
#menu a:hover { width: 200px; }
#menu a span { opacity: 0; }
#menu a:hover span { opacity: 1; }
#menu .home-link:hover:before, #menu .home-link.active:before { color: #47a0e5; }
#menu .about-link:hover:before, #menu .about-link.active:before { color: #d94a53; }
#menu .portfolio-link:hover:before, #menu .portfolio-link.active:before { color: #f59416; }
#menu .blog-link:hover:before, #menu .blog-link.active:before { color: #5ebd66; }
#menu .contact-link:hover:before, #menu .contact-link.active:before { color: #bfa5c4; }
}
/* -- Content Area CSS -- */
section { padding: 3em 2em; }
footer { padding: 2em 0 .25em; background: #666; }
footer p { font-size: .75em; text-align: center; }
#home { background: #47a0e5; padding-top: 7em; }
#about { background: #d94a53; }
#portfolio { background: #f59416; }
#blog { background: #5ebd66; padding-top: 7em; }
#contact { background: #bfa5c4; }
label { display: block; font-size: .75em; margin: 0 0 .25em .5em; }
input, textarea { margin: 0 0 1em; padding: .5em; outline: 0; border: 1px solid #666; width: 75%; max-width: 400px; font-family: 'Open Sans'; }
input[type="submit"] { background: #47a0e5; width: auto; border: 0; padding: .5em 1em; font-size: .8em; color: #fff; cursor: pointer; transition: background 0.5s; }
input[type="submit"]:hover { background: #3F8FCC; }
function secHeight() {
var vpHeight = $(window).height();
$('section').css('min-height', vpHeight);
}
function mClose() {
if ($('#menu').hasClass('on')) {
$('#menu').addClass('off').removeClass('on');
}
}
function animatescroll(id) {
$('body, html').animate({
scrollTop: $(id).offset().top
}, 500);
}
function mSection() {
var topHome = $('#home').offset().top,
topAbout = $('#about').offset().top,
topPort = $('#portfolio').offset().top,
topBlog = $('#blog').offset().top,
topCont = $('#contact').offset().top,
menuAll = $('#menu a').removeClass('active');
if ($(window).scrollTop() < topAbout) {
menuAll;
$('#menu a:contains("Home")').addClass('active');
} else if ($(window).scrollTop() >= topCont) {
menuAll;
$('#menu a:contains("Contact")').addClass('active');
} else if ($(window).scrollTop() >= topBlog) {
menuAll;
$('#menu a:contains("Blog")').addClass('active');
} else if ($(window).scrollTop() >= topPort) {
menuAll;
$('#menu a:contains("Portfolio")').addClass('active');
} else if ($(window).scrollTop() >= topAbout) {
menuAll;
$('#menu a:contains("About")').addClass('active');
}
}
$(document).ready(function(){
var menu = $('#menu');
$('.icon').click(function() {
menu.toggleClass('on').toggleClass('off');
});
var menuItem = $('#menu a');
menuItem.click(function() {
if (!$(this).hasClass('active')) {
menuItem.removeClass('active');
$(this).addClass('active');
}
});
secHeight();
if ($('.icon').css('display') == 'none') {
$('#menu').removeClass('off').removeClass('on');
} else if ($('.icon').css('display') == 'block' && !$('#menu').is('.off, .on')) {
$('#menu').addClass('off');
}
});
$(window).resize(function(){
secHeight();
if ($('.icon').css('display') == 'none') {
$('#menu').removeClass('off').removeClass('on');
} else if ($('.icon').css('display') == 'block' && !$('#menu').is('.off, .on')) {
$('#menu').addClass('off');
}
});
$(window).scroll(function() {
mClose(); mSection();
});
$(document).mouseup(function(e) {
var container = $('#menu');
if (!container.is(e.target) && container.has(e.target).length === 0 && container.hasClass('on') && !$('.icon').is(e.target)) {
container.addClass('off').removeClass('on');
}
});
Also see: Tab Triggers