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.
<!--Pattern HTML-->
<div id="pattern" class="pattern mod">
<!--Begin Pattern HTML-->
<header class="header">
<a href="#f-nav" class="f-nav-link">Menu</a>
</header>
<div class="lorem">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer iaculis dignissim orci viverra venenatis. Nulla sit amet quam at nisl sagittis adipiscing in a ligula. Nam in nisi neque. Ut in ipsum eget justo dignissim accumsan a sit amet neque. Nulla facilisi. Aliquam erat volutpat. Aliquam aliquet bibendum mollis. Aliquam erat volutpat. Sed commodo elit ac neque eleifend in commodo justo elementum. Curabitur tristique, odio id convallis aliquet, nibh augue sollicitudin lacus, at fermentum sem dolor eu lacus. Proin gravida dui in libero aliquet quis egestas odio dictum. Fusce in ligula vitae ante mollis viverra. Curabitur nibh felis, ornare ut tempor sed, lobortis id elit. Phasellus nec semper lorem. Pellentesque erat augue, tincidunt sed vulputate et, congue nec felis. Sed ligula metus, condimentum non commodo et, varius varius nisi.</p>
<p>Nunc arcu justo, elementum ac accumsan id, porttitor ac sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec lectus eros, dignissim sit amet viverra et, vulputate gravida dui. Donec at mattis tellus. Suspendisse nisi purus, porttitor in lacinia ornare, malesuada non dolor. Praesent ligula massa, blandit nec consequat et, sagittis ut purus. Aliquam erat volutpat. Maecenas a arcu ligula. Proin vitae eros purus, eu adipiscing orci. Nunc vestibulum, ante quis venenatis facilisis, lacus arcu gravida arcu, eget varius nibh lacus et leo. Aliquam lacinia, mi et convallis tincidunt, massa tellus accumsan felis, at consequat lacus ligula non leo. Pellentesque auctor ipsum lorem, ut feugiat purus. Mauris sed tellus orci, in pharetra dui. Morbi vestibulum lectus nec nulla bibendum mollis.</p>
<p>Donec nulla nisi, dictum auctor aliquet a, ultrices quis ipsum. Nam bibendum arcu in quam condimentum ut aliquet odio luctus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacus nulla, laoreet a fermentum vel, scelerisque sed mi. In consectetur magna sed leo scelerisque id mattis enim vulputate. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In cursus vulputate mauris et semper. Nam sed rhoncus justo. Duis quis orci quis lorem egestas mattis et in risus. Aenean justo eros, luctus sit amet ultricies et, interdum non est.</p>
<p>Donec vulputate leo quis odio faucibus dignissim. Proin sit amet sem massa. Pellentesque sed nisi lacus, dictum condimentum purus. Praesent aliquam volutpat nulla, non adipiscing urna tempor nec. Praesent eu nulla sem. Aenean sed velit vitae justo lobortis mattis. Integer vitae orci quis quam varius imperdiet in et eros. Cras at justo a nunc vulputate mattis. Nam at quam odio, vel egestas sapien. Duis facilisis eros non diam iaculis in mattis orci tincidunt. Mauris adipiscing sollicitudin vestibulum.</p>
<p>Curabitur dignissim lacinia nibh eu laoreet. Cras vitae mauris ligula. Curabitur sodales orci in neque pretium non ultricies arcu condimentum. Suspendisse sit amet felis vitae tortor molestie gravida sed sit amet sapien. Sed eget dui ante. Phasellus vel odio tellus. Proin euismod enim ut velit ultricies vestibulum.</p>
</div>
<footer>
<ul id="f-nav" class="f-nav" role="navigation">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</footer>
</div>
<!--End Pattern HTML-->
<div class="container">
<section class="pattern-description">
<h1>Footer Anchor</h1>
<p>This clever solution keeps the nav list at the footer of the site, while the header contains a simple anchor link pointing to the footer nav. This approach clears up a lot of room for the core content while still providing quick access to the navigation.</p>
<h3>Pros</h3>
<ul>
<li><strong>Easy to implement</strong>- Simple anchor on top. Nav list on the bottom. That’s pretty damn easy.</li>
<li><strong>No Javascript dependency</strong>- which means less testing and far better support.
<li><strong>Little CSS work required to scale up</strong> – Thanks to absolute or fixed positioning, moving the footer nav up to the top for large screens is a piece of cake.</li>
<li><strong>Single button in header</strong>- A simple menu icon or link takes up very little room in the header, which frees up plenty of space for the core content</li>
</ul>
<h3>Cons</h3>
<ul>
<li><strong>Anchor jump can be awkward/disorienting</strong> – Quickly jumping to the footer of the site can be a bit disorientating. </li>
<li><strong>Not elegant</strong>- this seems weird to say, but other methods like the <a href="#toggle">toggle method</a> have a bit of sexy to them. A jarring jump, while awesomely practical, isn’t the elegant interaction mobile users have gotten used to from interacting with those highly-polished native apps.</li>
</ul>
<h3>In the Wild</h3>
<ul>
<li><a href="http://greygoose.com">Grey Goose</a></li>
<li><a href="http://contentsmagazine.com/">Contents Magazine</a></li>
<li><a href="https://bagcheck.com/home">Bagcheck</a> (I know <a href="http://www.lukew.com/ff/entry.asp?1390">it’s not responsive</a>, but it’s where the technique was popularized)</li>
</ul>
<h3>Resources</h3>
<ul>
<li><a href="https://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/a-simple-responsive-mobile-first-navigation/">A Simple, Responsive, Mobile First Navigation</a></li>
<li><a href="http://www.abookapart.com/products/mobile-first">Mobile First Book</a></li>
</ul>
</section>
<footer role="contentinfo">
<div>
<nav id="menu">
<a href="https://bradfrost.github.com/this-is-responsive/patterns.html">←More Responsive Patterns</a>
</nav>
</div>
</footer>
</div>
.header {
margin-bottom: 2em;
text-align: right;
}
.f-nav {
border-top: 1px solid #808080;
margin: 0 -1em;
}
.f-nav li a {
display: block;
padding: 0.8em 1em;
border-bottom: 1px solid #808080;
}
@media screen and (min-width: 40em) {
.f-nav-link {
display: none;
}
.f-nav {
position: absolute;
top: 0;
left: 0;
border: 0;
margin: 0;
}
.f-nav li {
display: inline-block;
margin-right: 0.25em;
}
.f-nav li a {
border: 0;
}
}
Also see: Tab Triggers