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 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.
<header role="banner">
<h1 class="fcurtain-identity">Fixed Curtains</h1>
<nav role="navigation">
<a href="">link 1</a>
<a href="">link 2</a>
<a href="">link 3</a>
</nav>
</header>
<main role="main">
<section class="fcurtain--cover fcurtain--callout">
<h2>A Sassy Layout Pattern for Authors</h2>
<p>Scroll down to learn more about this HTML template</p>
</section>
<section class="fcurtain">
<header>
<h1>Getting Started</h1>
</header>
<p>This template uses <abbr title="cascading stylesheets">CSS</abbr> properties for layout such as <a href="//caniuse.com/#search=flexbox"><code>flexbox</code></a> and <a href="//caniuse.com/#search=calc"><code>calc()</code></a> as well as the <code>fixed</code> value for <code>background-attachment</code>. I've also used the <a href="//caniuse.com/#search=nth-of-type"><code>nth-of-type()</code></a> selector to style each curtain's background image individually.</p>
<p><b>Does it work on IE8?</b> You'll need to consider your own fallbacks for a minimum of IE8, but make sure to double check 9-11 as well. I didn't write IE fallbacks for you which is why you're getting this for free yo.</p>
<p><b>What about that sweet <abbr title="responsive web design">RWD?</abbr></b> I'll let you take care of that business since it's a unique thing based on your unique needs. Once again it's free, but keep an eye our for a paid version in the future with better features like <abbr title="responsive web design">RWD</abbr>, Performance Optimizing, Additional Functionality and Support.</p>
<p><b>What else is going on?</b> ARIA roles are baked in plus I made this template super clean for you to get started by ensuring removeable items are super easy to remove. Authors can also declare the height of the fixed panels using a Sass variable and passing either <code>fixed</code> or <code>full</code>. You're also on your own for a grid system should you choose to use one. Now all that's left to do is copy this Markup and Sass and get to work.</p>
</section>
<section class="fcurtain--cover fcurtain--callout">
<h2>Go to 11</h2>
</section>
<section class="fcurtain">
<header>
<h1>Turn that volume up</h1>
</header>
<p>Wanna make this template really awesome? Why not add some media queries or even a fancy ass JavaScript thingy. You could also use something like the <code>picture</code> element or <code>srcset</code> to help control these massive background images for various screen dimensions. Anyways, here's some more lorem ipsum that I know you love so much.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio culpa, praesentium eius veniam odio recusandae sed deserunt fuga assumenda explicabo. Nobis omnis nulla illo enim, temporibus maxime qui repellat atque!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio culpa, praesentium eius veniam odio recusandae sed deserunt fuga assumenda explicabo. Nobis omnis nulla illo enim, temporibus maxime qui repellat atque!</p>
</section>
<section class="fcurtain--cover fcurtain--callout">
<h2>Section Intro</h2>
</section>
<section class="fcurtain">
<header>
<h1>Section Title</h1>
</header>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio culpa, praesentium eius veniam odio recusandae sed deserunt fuga assumenda explicabo. Nobis omnis nulla illo enim, temporibus maxime qui repellat atque!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio culpa, praesentium eius veniam odio recusandae sed deserunt fuga assumenda explicabo. Nobis omnis nulla illo enim, temporibus maxime qui repellat atque!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio culpa, praesentium eius veniam odio recusandae sed deserunt fuga assumenda explicabo. Nobis omnis nulla illo enim, temporibus maxime qui repellat atque!</p>
</section>
<footer role="contentinfo">
<small>Fixed Curtains ©2014 all rights reserved</small>
</footer>
</main>
// Demo Crap
*{&:before, &:after{box-sizing: inherit;}}html{box-sizing: border-box;font-family:'Droid Serif',serif;font-size: 100%;line-height:1.5;}header[role="banner"]{padding: 20px;}footer[role="contentinfo"]{background:#253537;color:white;}h2{margin-bottom: 0;}nav a{color: #071A24;padding:0 5px;text-decoration: none;}
// Required Styles & Config
// READ FIRST:
// This demo uses normalize and autoprefixer. I strongly suggest that you find
// something to prefix junk for you otherwise you're writing it out by hand.
$fcurtain_lgscr: 640px;
$fcurtain_type: full; // accepts [full,fixed]
$fcurtain_height: null; // accepts px value if height is fixed (i.e. 340px)
$fcurtain_bg: #EFE99D;
$fcurtain_bgimg: (
// panel position : panel image
1 : 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/392/mountain-peaks.jpg',
3 : 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/392/geometric-mountains.jpg',
5 : 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/392/mountain-gaze.jpg'
);
html,
body,
main {
height: 100%;
}
header[role="banner"] {
display: flex;
align-items: center;
position: absolute;
top: 0;
left: 0;
right: 0;
width: auto;
z-index: 1;
}
.fc-identity {
flex: 5;
}
nav[role="navigation"] {
flex: 5;
text-align: right;
}
main[role="main"] > * {
max-width: $fcurtain_lgscr;
padding: 1.65em calc(50% - #{$fcurtain_lgscr/2});
}
.fcurtain--cover {
@if $fcurtain_type == full {
min-height: 100%;
} @elseif $fcurtain_type == fixed {
height: $fcurtain_height;
}
position: relative;
background-size: cover;
background-attachment: fixed;
background-positon: center center;
background-repeat: no-repeat;
background-color: $fcurtain_bg;
@each $key, $value in $fcurtain_bgimg {
&:nth-of-type(#{$key}) {
background-image: url(#{$value});
}
}
}
.fcurtain--callout {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
}
Also see: Tab Triggers