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 URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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 id="wrapper">
<header id="js-header">
<div class="container clearfix">
<h1 id="logo">Apples</h1>
<nav>
<a href="#bacon">Bacon</a>
<a href="#sausage">Sausage</a>
<a href="#biltong">Biltong</a>
</nav>
</div>
</header>
<div id="main">
<div id="content">
<section>
<div class="container">
<h1>I Second That Emotion</h1>
<p>Aww, it's true. I've been hiding it for so long. Perhaps, but perhaps your civilization is merely the sewer of an even greater society above you! You guys go on without me! I'm going to go… look for more stuff to steal! When I was first asked to make a film about my nephew, Hubert Farnsworth, I thought "Why should I?" Then later, Leela made the film. But if I did make it, you can bet there would have been more topless women on motorcycles. Roll film! So I really am important? How I feel when I'm drunk is correct? Is the Space Pope reptilian!?</p>
<p>Bacon atball corned beef strip steak andouille.</p>
</div>
</section>
<section class="color">
<div class="container">
<h1>The Duh-Vinci Code</h1>
<p>Bender, you risked your life to save me! Good news, everyone! I've taught the toaster to feel love! I can explain. It's very valuable. Can we have Bender Burgers again?
For the last time, I don't like lilacs! Your 'first' wife was the one who liked lilacs! You seem malnourished. Are you suffering from intestinal parasites? Say what? Now, now. Perfectly symmetrical violence never solved anything. Eeeee! Now say "nuclear wessels"! Ugh, it's filthy! Why not create a National Endowment for Strip Clubs while we're at it?
I suppose I could part with 'one' and still be feared… Noooooo! Have you ever tried just turning off the TV, sitting down with your children, and hitting them?
Isn't it true that you have been paid for your testimony? All I want is to be a monkey of moderate intelligence who wears a suit… that's why I'm transferring to business school! We'll need to have a look inside you with this camera. Really?!</p>
<p>Bacon ipsum dolor sit amet pig biltong filet mignon, kiel</p>
</div>
</section>
<section>
<div class="container">
<h1>A Bicyclops Built For Two</h1>
<p>I decline the title of Iron Cook and accept the lesser title of Zinc Saucier, which I just made up. Uhh… also, comes with double prize money. Ugh, it's filthy! Why not create a National Endowment for Strip Clubs while we're at it? Oh dear! She's stuck in an infinite loop, and he's an idiot! Well, that's love for you. For the last time, I don't like lilacs! Your 'first' wife was the one who liked lilacs! I was having the most wonderful dream. Except you were there, and you were there, and you were there! You guys go on without me! I'm going to go… look for more stuff to steal!</p>
<p>Bacon </p>
</div>
</section>
</div>
</div>
<footer>
<div class="container clearfix">
<div class ="col" id="col-1">
<ul>
<li>APPLES</li>
<li><a href="#0">Home</a></li>
<li><a href="#0">Services</a></li>
<li><a href="#0">Contact</a></li>
<li><a href="#0">Sitemap</a></li>
</ul>
</div>
<div class ="col" id="col-2">
<ul>
<li>SOCIAL</li>
<li><a href="#0">Facebook</a></li>
<li><a href="#0">Twitter</a></li>
<li><a href="#0">LinkedIn</a></li>
</ul>
</div>
<div class ="col" id="col-3">
<ul>
<li>SERVICES</li>
<li><a href="#0">Bacon</a></li>
<li><a href="#0">Sausage Services</a></li>
<li><a href="#0">Cheese</a></li>
<li><a href="#0">Cider Apples</a></li>
</ul>
</div>
<div id="copy">© Designed and built by <a href="https://twitter.com/lilianakastilio">@liianakastilio</a> 2013 - 2014</div>
</div>
</footer>
</div>
header.smaller {
height: 75px;
}
header.smaller h1#logo {
width: 150px;
height: 75px;
line-height: 55px;
font-size: 55px;
margin: 0;
}
header.smaller nav a {
line-height: 75px;
}
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
color: #505050;
font-family: "Open Sans", sans-serif;
font-weight: 300;
font-size: 16px;
line-height: 1.8;
}
h1, h2, h3, h4, h5, h6 {
line-height: 1;
font-weight: 100;
color: #77C7AC;
}
a {
text-decoration: none;
color: #fcfcfc;
font-weight: 300;
}
a:hover {
color: #3c3c3c;
}
#wrapper {
width: 100%;
margin: 0 auto;
}
#main {
background-color: #fff;
padding-top: 150px;
min-height:500px;
}
.container {
width: 80%;
margin: 0 auto;
padding: 0 30px;
}
section {
padding: 60px 0;
}
section h1 {
font-weight: 700;
margin-bottom: 10px;
}
section p {
margin-bottom: 30px;
}
section p:last-child {
margin-bottom: 0;
}
section.color {
background-color: #f4f4f4;
}
header {
width: 100%;
height: 10em;
overflow: hidden;
position: fixed;
top: 0;
left: 0;
z-index: 999;
border-bottom:solid 0.5em #f4f4f4;
background-color: #394e63;
transition: height 0.3s;
}
header h1#logo {
display: inline-block;
line-height:3em;
margin: 0;
padding:0 1em;
background-color:#fd5559;
float: left;
font-family: "Open Sans", sans-serif;
font-size: 60px;
color: #fcfcfc;
text-shadow: 0.1em 0.03em #C0392B;
font-weight: 400;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
header nav {
display: inline-block;
float: right;
}
header nav a {
line-height: 150px;
margin-left: 20px;
color: #fcfcfc;
font-weight: 300;
font-size: 1em;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
header nav a:hover {
color: #fd5559;
}
header.smaller {
height: 75px;
}
header.smaller h1#logo {
line-height: 75px;
font-size: 30px;
}
header.smaller nav a {
line-height: 75px;
}
footer {
background-color: #3c3c3c;
text-align: center;
min-height:17em;
color: #bababa;
}
footer a {
display: inline-block;
margin: 0;
text-decoration:underline;
}
footer div.col {
width:20%;
display:inline-block;
vertical-align: top;
}
footer col a {
display:block;
}
footer ul li a:hover {
color: #fd5559;
}
footer ul li a {
color: #bababa;
}
footer div#copy {
margin-top: 1em;
padding:0;
}
footer div#copy a {
color: #fd5559;
}
footer div.container {
position:relative;
}
footer ul{
list-style:none;
margin-top:2em;
padding:0;
}
footer ul li {
text-align:left;
margin:0;
padding:0;
}
.clearfix:after {
visibility: hidden;
display: block;
content: "";
clear: both;
height: 0;
}
@media all and (max-width: 760px) {
header h1#logo {
display: block;
float: none;
margin: 0 auto;
height: 100px;
line-height: 80px;
text-align: center;
}
header nav {
display: block;
float: none;
height: 50px;
text-align: center;
margin: 0 auto;
}
header nav a {
line-height: 50px;
margin: 0 10px;
}
header.smaller {
height: 75px;
}
header.smaller h1#logo {
height: 40px;
line-height: 40px;
font-size: 30px;
width:100%;
}
header.smaller nav {
height: 35px;
}
header.smaller nav a {
line-height: 35px;
}
footer div.col {
width:100%;
display:inline-block;
vertical-align: top;
}
footer ul li {
display:inline-block;
margin:0 0.5em;
float:left;
}
}
@media all and (max-width: 600px) {
.container {
width: 100%;
}
footer a {
display: block;
}
}
function resizeHeaderOnScroll() {
const distanceY = window.pageYOffset || document.documentElement.scrollTop,
shrinkOn = 200,
headerEl = document.getElementById('js-header');
if (distanceY > shrinkOn) {
headerEl.classList.add("smaller");
} else {
headerEl.classList.remove("smaller");
}
}
window.addEventListener('scroll', resizeHeaderOnScroll);
Also see: Tab Triggers