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.
<header>
<h1 class="logo">Logo</h1>
</header>
<nav>
<ul>
<li class="nav-item"><a href="#" >Home</a></li>
<li class="nav-item"><a href="#" >Blog</a></li>
<li class="nav-item"><a href="#">About</a></li>
<li class="nav-item"><a href="#" >Contact</a></li>
</ul>
<div class="menu-bar">Menu
<span class="hamburger-icon"><i class="fa fa-bars"></i></span>
</div>
</nav>
<div class="container">
<div class="section">
<div class="col span_2_of_3">
<div class="blog-post">
<h1 class="blog-title">Title</h1>
<h2 class="date">Posted 28th Feb 2015</h2>
<p class="blog-content">Ut noster tractavissent, summis hic eiusmod te quem. Doctrina velit litteris eu
eu fore ingeniis philosophari ne quid o ingeniis ne anim, illum ea iudicem. Pariatur duis dolor hic dolor ad vidisse amet elit ita summis, quo duis te malis, velit nostrud ingeniis. Appellat elit tamen iudicem multos, mentitum quae sed appellat illustriora. Velit commodo cernantur se si anim do labore, probant ab aliqua aut non laborum fidelissimae. Ex quae se fugiat, et malis officia in et enim cillum ita incididunt, a irure amet an ingeniis.</p>
<a href="#" class="post-link">Read More...</a>
</div>
<div class="blog-post">
<h1 class="blog-title">Title</h1>
<h2 class="date">Posted 22nd Feb 2015</h2>
<p class="blog-content">Dolor offendit et consectetur, ut mandaremus est litteris, noster ab ab labore cernantur eu nulla incurreret imitarentur, qui fore malis e doctrina, de anim esse do appellat, proident sint litteris, anim arbitror consequat. Proident illum nulla laborum fore. Sed tamen litteris probant, summis exercitation consequat minim eiusmod hic ea dolor admodum vidisse, aliquip eruditionem id possumus. Si lorem ex culpa. Summis eiusmod a mentitum. Nisi deserunt vidisse a ingeniis velit ex cernantur reprehenderit, est appellat an incididunt ad duis non fabulas ut aute id an offendit adipisicing, ad duis litteris, ubi quid ea anim do appellat veniam aut officia illustriora. Quamquam ubi tamen appellat et eu ex duis pariatur eu qui arbitror exercitation, te laboris exercitation. Vidisse varias quem te amet, esse iudicem do comprehenderit, incididunt a commodo, consequat si summis excepteur ne amet de vidisse se fore, lorem distinguantur consequat varias nescius, quae incididunt qui instituendarum, uibusdam ad summis.</p>
<a href="#" class="post-link">Read More...</a>
</div>
<div class="blog-post">
<h1 class="blog-title">Title</h1>
<h2 class="date">Posted 12th Feb 2015</h2>
<p class="blog-content">Expetendis qui probant, enim arbitror de enim irure ubi e arbitror praetermissum, nulla de probant. Velit incididunt et sint quorum. Ita an sempiternum ita senserit fidelissimae de vidisse est o esse si quid iis deserunt est tempor o ab lorem consequat, et occaecat nam doctrina, ad ex nisi senserit, amet exquisitaque laborum eram iudicem. Sed id cillum aliquip, nulla e de fugiat ingeniis. Eiusmod amet aliqua appellat sunt. Ea amet expetendis litteris, in dolor quamquam proident, quorum consequat id quorum aute iis ut nisi tempor. Ea senserit ne senserit. Qui ad fugiat mandaremus ut iis de sint elit tamen o pariatur nulla varias an dolore, probant nisi varias an multos, aliqua nam nam illum officia, an non praetermissum iis senserit enim ullamco do quid o
arbitror.</p>
<a href="#" class="post-link">Read More...</a>
</div>
</div>
<aside class="col span_1_of_3">
<div class="side-post">
<img src="http://placehold.it/800x400&text=img" alt="img">
<p class="side-content">Ut noster tractavissent, summis hic eiusmod te quem. Doctrina velit litteris eu eu fore ingeniis philosophari ne quid o ingeniis ne anim, illum ea iudicem. Pariatur duis dolor hic dolor ad vidisse amet elit ita summis, quo duis te malis.</p>
</div>
<div class="side-post">
<p class="side-content">Ultricies lacus et, non orci gravida purus augue integer, sed turpis. Erat dapibus. Eleifend massa scelerisque, aenean penatibus laoreet ut in.</p>
<a href="#" class="button">Subscribe!</a>
</div>
</aside>
</div>
</div>
/* Base Styles */
body{
margin: 0;
padding: 0;
font-size: 16px;
line-height: 1.4em;
color: #222;
background: #474747;
font-family: 'Lato', sans-serif;
}
img{
max-width: 100%;
height: auto;
border-radius: 3px;
}
a{
text-decoration: none;
color: inherit;
}
/* Grid */
.section {
clear: both;
padding: 0;
margin: 0;
}
.col {
display: block;
float:left;
margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; }
.span_3_of_3 {
width: 100%;
}
.span_2_of_3 {
width: 66.1%;
}
.span_1_of_3 {
width: 32.2%;
}
/* Header & Navigation */
header{
max-width: 100%;
background: #222; /*FallBack*/
background: rgba(0,0,0,.6);
padding: 20px;
}
nav{
width: 100%;
margin-bottom: 1em;
background: #323232;
font-family: 'Poiret One', cursive;
}
.logo{
text-align: center;
color: #fff;
font-size: 3em;
font-weight: 400;
font-family: 'Poiret One', cursive;
}
ul{
padding: 0;
margin: 0;
overflow: hidden;
color: #fff;
text-align: center;
-webkit-transition: max-height 0.5s;
transition: max-height 0.5s;
}
.nav-item{
display: inline-block;
padding: 20px;
font-size: 1.4em;
-webkit-transition: background .5s;
transition: background .5s
}
.nav-item:hover{
background: #474747;
cursor: pointer;
}
.menu-bar{
width: 100%;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
background: #2d2d2d;
text-align: left;
padding: 15px 20px;
color: #fff;
font-size: 1.4em;
cursor: pointer;
display: none;
}
.hamburger-icon{
float: right;
clear: both;
margin-top: -5px;
font-size: 1.4em;
}
/* Blog Posts */
.container{
max-width: 1020px;
margin: 0 auto;
padding: 20px;
}
.blog-post{
background: #fff;
margin: 0 auto 2em auto;
padding: 35px 30px;
box-shadow: 5px 5px 15px -1px rgba(0,0,0,0.3);
}
.side-post{
background: #fff;
margin: 0 auto 1.5em auto;
width: 15em;
padding: 20px;
}
.blog-content{
font-size: 1em;
border-left: 5px solid #8EE5EE;
padding-left: 15px;
}
.side-content{
font-size: .9em;
margin-top: 8px;
margin-bottom: 0;
}
.blog-title{
font-size: 2.5em;
margin-top: 5px;
}
.date{
font-size: 1em;
font-weight: 400;
color: #9C9C9C;
margin-top: -10px;
text-decoration: underline;
text-decoration-color: currentColor;
}
.post-link{
color: #009ACD;
font-style: italic;
transition: all 0.4s;
}
.post-link:hover{
color: #005c7b;
text-decoration: underline;
text-decoration-color: currentColor;
cursor: pointer;
}
/* Button */
.button{
display: block;
padding: 15px 20px;
margin-top: .8em;
background: #009ACD;
text-align: center;
color: #fff;
font-size: 1.4em;
border-radius: 3px;
transition: all .4s ease-in;
}
.button:hover{
background: #005c7b;
}
/*Media Queries*/
/* @900px*/
@media only screen and (max-width: 56.25em) {
.col{ margin: 1% 0 1% 0%;}
.span_3_of_3, .span_2_of_3, .span_1_of_3{ width: 100%; }
.side-post{ width: 42%;
float: left;
margin: -2% 0 1% 1.6%;}
}
/* @685px*/
@media only screen and (max-width: 42.813em) {
.side-post{ width: auto;
padding: 15px;
margin: -2% auto 8% auto; }
.blog-title{ font-size: 1.95em; }
.date{ font-size: .9em; }
}
/* @480px */
@media only screen and (max-width: 30em){
nav ul{ max-height: 0; }
.reveal{ max-height:19em; }
nav ul .nav-item{ -webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
width:100%;
padding: 15px; }
.menu-bar{ display: block; }
}
/* @380px*/
@media only screen and (max-width: 23.75em) {
.blog-content, .post-link{ font-size: .9em; }
.side-content{ font-size: .8em; }
.button{ padding: 10px 15px; }
.nav-item{ font-size: 1.2em; }
}
$('.menu-bar').on('click', function(){
$('nav ul').toggleClass('reveal');
});
Also see: Tab Triggers