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="grid">
<header class="grid__col--12 panel--padded--centered" role="banner">
<a class="site-logo" href="/">
<b class="srt">Poly - UI Toolkit</b>
</a>
<nav class="navbar" role="navigation">
<span id="toggle" class="icn--nav-toggle is-displayed-mobile">
<b class="srt">Toggle</b>
</span>
<ul class="nav is-collapsed-mobile">
<li class="nav__item"><a href="#type">Typography</a></li>
<li class="nav__item"><a href="#buttons">Buttons</a></li>
<li class="nav__item"><a href="#forms">Form</a></li>
<li class="nav__item"><a href="#progbars">Bars</a></li>
<li class="nav__item"><a href="#images">Images</a></li>
<li class="nav__item"><a href="#grid">Grid</a></li>
<li class="nav__item--current"><a href="#nav">Navigation</a></li>
</ul>
</nav>
</header>
</div>
<div class="grid is-hidden-mobile">
<div class="grid__col--12">
<img class="img--hero" src="https://treehouse-code-samples.s3.amazonaws.com/poly/img/hero.jpg" alt="Poly - A simple UI Kit">
</div>
</div>
<h4 id="type" class="grid">Typography</h4>
<div class="grid">
<div class="centered grid__col--8">
<h1 class="headline-primary--grouped">Take a look at this amazing headline</h1>
<h2 class="headline-secondary--grouped">Don't forget about the subtitle</h2>
<p>This is a typical paragraph for the UI Kit. <a href="#">Here is what a link might look like</a>. The typical font family for this kit is Helvetica Neue. This kit is intended for clean and refreshing web layouts. No jazz hands here, just the essentials to make dreams come true, with minimal clean web design. The kit comes fully equipped with everything from full responsive media styling to buttons to form fields. <em>I enjoy using italics as well from time to time</em>. Fell free to create the most amazing designs ever with this kit. I truly hope you enjoy not only the kit but this amazing paragraph as well. :)</p>
<blockquote>You know what really gets me going? A really nice set of block quotes. That's right, block quotes that say, "Hey, I'm an article you want to read and nurture."</blockquote>
</div>
</div>
<h4 id="buttons" class="grid">Buttons</h4>
<div class="grid">
<div class="grid__col--12">
<a class="btn--default" href="#">Button Default</a>
<a class="btn--success" href="#">Button Success</a>
<a class="btn--error" href="#">Button Error</a>
<button class="btn--warning">Button Warning</button>
<button class="btn--info">Button Info</button>
</div>
</div>
<h4 id="forms" class="grid">Form Elements</h4>
<div class="grid">
<div class="grid__col--7">
<form class="form">
<label class="form__label--hidden" for="name">Name:</label>
<input class="form__input" type="text" id="name" placeholder="Name">
<label class="form__label--hidden" for="email">Email:</label>
<input class="form__input" type="email" id="email" placeholder="email@website.com">
<label class="form__label--hidden" for="msg">Message:</label>
<textarea class="form__input" id="msg" placeholder="Message..." rows="7"></textarea>
<input class="btn--default" type="submit" value="Submit">
<input class="btn--warning" type="reset" value="Reset">
</form>
</div>
<div class="grid__col--4">
<img class="img--avatar" src="https://treehouse-code-samples.s3.amazonaws.com/poly/img/avatar.png" alt="Avatar">
<form>
<label class="form__label--hidden" for="username">Username:</label>
<input class="form__input" type="text" id="username" placeholder="Username">
<label class="form__label--hidden" for="password">Password:</label>
<input class="form__input" type="password" id="password" placeholder="Password">
<input class="form__btn" type="submit" value="Login">
</form>
</div>
</div>
<h4 id="progbars" class="grid">Progress Bars</h4>
<div class="grid">
<div class="grid__col--12">
<div class="progbar">
<span class="progbar__status--default"></span>
</div>
<div class="progbar">
<span class="progbar__status--success"></span>
</div>
<div class="progbar">
<span class="progbar__status--error"></span>
</div>
<div class="progbar">
<span class="progbar__status--warning"></span>
</div>
<div class="progbar">
<span class="progbar__status--info"></span>
</div>
</div>
</div>
<h4 id="images" class="grid">Images</h4>
<div class="grid">
<div class="grid__col--5">
<img src="https://treehouse-code-samples.s3.amazonaws.com/poly/img/sample.jpg" alt="sample image">
</div>
<div class="grid__col--5">
<img class="img--wrap" src="https://treehouse-code-samples.s3.amazonaws.com/poly/img/sample.jpg" alt="sample image">
</div>
<div class="grid__col--2">
<img class="img--avatar" src="https://treehouse-code-samples.s3.amazonaws.com/poly/img/avatar.png" alt="Avatar">
</div>
</div>
<h4 id="grid" class="grid">Grid System</h4>
<div class="theme__poly">
<div class="grid">
<div class="grid__col--12">.grid__col--12</div>
</div>
<div class="grid">
<div class="grid__col--6">.grid__col--6</div>
<div class="grid__col--6">.grid__col--6</div>
</div>
<div class="grid">
<div class="grid__col--4">.grid__col--4</div>
<div class="grid__col--4">.grid__col--4</div>
<div class="grid__col--4">.grid__col--4</div>
</div>
<div class="grid">
<div class="grid__col--3">.grid__col--3</div>
<div class="grid__col--3">.grid__col--3</div>
<div class="grid__col--3">.grid__col--3</div>
<div class="grid__col--3">.grid__col--3</div>
</div>
<div class="grid">
<div class="grid__col--5">.grid__col--5</div>
<div class="grid__col--7">.grid__col--7</div>
</div>
<div class="grid">
<div class="grid__col--8">.grid__col--8</div>
<div class="grid__col--4">.grid__col--4</div>
</div>
<div class="grid">
<div class="centered grid__col--7">.centered .grid__col--7</div>
</div>
</div>
<div class="grid">
<div class="grid__col--7">
<h4 id="nav">Navigation</h4>
<ul class="nav" role="navigation">
<li class="nav__item"><a href="#">Nav Link</a></li>
<li class="nav__item"><a href="#">Nav Link 2</a>
<li class="nav__item--current"><a href="#">Nav Current</a></li>
</ul>
<p>This is what the navigation menu looks like when the screen is at 769px or higher. When the screen is less than 769px, you will have the option to display a toggle menu icon.</p>
</div>
<div class="grid__col--4">
<h4>Offcanvas Menu</h4>
<div class="offcanvas">
<span class="icn--close">
<b class="srt">close</b>
</span>
<ul class="menu" role="navigation">
<a class="menu__link" href="#">Link 1</a>
<a class="menu__link" href="#">Link 2</a>
<a class="menu__link" href="#">Link 3</a>
<a class="menu__link--end" href="#">Link 4</a>
</ul>
</div>
</div>
</div>
<h4 class="grid">Footer</h4>
<div class="grid">
<footer class="grid__col--12 panel--padded--centered" role="contentinfo">
<a class="site-logo" href="#">
<b class="srt">Poly - UI Toolkit</b>
</a>
<p>A simple UI Kit for everyone to share and enjoy. <a href="https://github.com/Guilh/Poly"> Grab it from GitHub</a>.</p>
</footer>
</div>
/*
Grab all the files on GitHub: https://github.com/Guilh/Poly
Watch the Treehouse course "Modular CSS with Sass" to see how I built Poly: http://teamtreehouse.com/library/modular-css-with-sass
Design by @MatHelme
*/
$('#toggle').click(function() {
$(this).next('.nav').toggleClass("is-collapsed-mobile");
});
Also see: Tab Triggers