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.
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300|Raleway:200,900|Over+the+Rainbow' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, user-scalable=no">
<header>
<div class="hero">
<div class="hamb-wrap">
<div class="hamb"></div>
</div>
<p class="logo">Bill Murray</p>
<nav>
<ul>
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">CV</a>
</li>
<li>
<a href="#">Blog</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
</nav>
</div>
</header>
<section class="content">
<h1>Page Name</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam vitae officiis distinctio libero deleniti dolorem quae vero nemo modi cupiditate delectus quo iure pariatur nulla doloremque odio minima beatae totam! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam itaque nemo cupiditate commodi velit praesentium perspiciatis nesciunt quas eveniet alias porro veritatis sit cum est necessitatibus possimus illum qui recusandae optio vel illo amet unde quidem perferendis consequatur officiis provident ex impedit repellat fuga enim eum a voluptatibus sequi voluptas soluta voluptatem corrupti minus accusamus ea accusantium laboriosam?</p>
<img /><img src="http://placehold.it/500x500&text=Image 2" class="fr" height="250" width="250"/><p>Eum sapiente architecto natus ducimus a placeat expedita dolore debitis amet omnis excepturi pariatur libero similique nobis neque sit perferendis mollitia quibusdam corporis atque illo. Excepturi repellendus architecto voluptates numquam cum tempora natus eligendi itaque labore provident deserunt incidunt commodi iste sint rem non et sapiente nesciunt debitis sit eius ad necessitatibus sequi totam illum doloremque officia similique est minus dignissimos distinctio placeat ipsa aut illo aliquid beatae iure!</p>
<p>Repellendus cupiditate voluptatibus eius sequi id corrupti tempore consectetur explicabo deleniti voluptate distinctio quae accusamus ipsum placeat tenetur dolorem nesciunt? Earum cum dicta libero quia qui culpa fuga nulla adipisci natus nesciunt! Impedit ut hic quisquam quos id. Dolorum eos assumenda ducimus illum quisquam doloribus culpa nisi ab amet quo quibusdam ipsa inventore vitae iste mollitia animi odio reiciendis cum non autem ea nihil nobis laborum harum recusandae error rerum facere asperiores officia cupiditate eveniet enim distinctio ex debitis nostrum obcaecati omnis. Aut ex recusandae sapiente saepe deserunt omnis quasi consequuntur excepturi atque sunt distinctio repellendus ipsam itaque explicabo sint tempora necessitatibus nulla amet veritatis mollitia id adipisci facere quisquam animi quaerat commodi ipsum modi eligendi vel maiores voluptatem dolores ab asperiores.</p>
<img src="http://placehold.it/500x500&text=Image 2" class="fl" height="250" width="250"/><p>Veniam tempora impedit sunt excepturi nisi expedita corporis voluptatum quod eum dolores cupiditate quo odit iure doloribus corrupti molestias minus nihil temporibus accusamus ex. Cumque pariatur deleniti ipsam ea cum asperiores non suscipit natus. Molestias enim optio perferendis voluptatibus suscipit laborum officia cupiditate similique illum reprehenderit porro natus soluta modi facilis eligendi illo aspernatur nemo fugit sequi facere a quo iure eaque rem omnis et voluptatem quibusdam excepturi nihil. Commodi incidunt quos voluptatum sunt explicabo nobis perferendis vel iusto excepturi cupiditate blanditiis magni placeat autem dignissimos dolor maxime soluta qui voluptate esse obcaecati in tempora est molestias harum adipisci ex deleniti nesciunt odio aspernatur facilis provident laborum eum veniam quis sapiente expedita corporis possimus aut recusandae voluptas nihil a.</p>
<p>Necessitatibus libero officia quaerat earum at ullam itaque dolorum. Eligendi illo culpa non quas sit commodi autem assumenda necessitatibus hic deserunt error quam reiciendis consequatur odio quo nostrum nam odit explicabo praesentium dolorum repellat ipsum placeat doloremque neque fugiat sapiente temporibus ad quis provident vitae maiores magnam numquam magni cum impedit dolorem animi voluptas qui deleniti sint. Obcaecati deserunt distinctio sapiente voluptate illo recusandae ad quod tenetur facere doloribus at perspiciatis beatae provident facilis reprehenderit dolorum ut aut dolor temporibus aperiam sunt quae vero modi magnam possimus sequi omnis aliquam. Rerum culpa vel voluptatem nihil aperiam temporibus mollitia odit earum quos rem placeat deleniti illum ea repellendus quisquam odio reprehenderit maxime provident quasi aliquam magnam autem reiciendis est dolorum similique facilis possimus adipisci modi quibusdam ipsam! Quia esse quae vero assumenda voluptatem!</p>
</section>
//layout
$leftWidth: 40%;
//navigation
$hamWidth: 35px;
$hamHeight: 3px;
$hamSpacing: 8px;
$menuTransition: .2s;
//general
*, *:before, *:after {
box-sizing: border-box;
}
html {
font-size: 21px;
font-family: 'Open Sans';
}
html, body {
height: 100%;
}
h1 {
font-family: 'Raleway';
font-size: 2.7em;
font-weight: 900;
text-transform: uppercase;
letter-spacing: -2px;
color: #222;
margin-bottom: .3em;
}
p {
font-weight: 200;
color: #525252;
}
//reusable classes
.fl {
float: left;
margin: 20px;
}
.fr {
float: right;
margin: 20px;
}
//specific
.hero {
width: $leftWidth;
height: 100%;
position: fixed;
background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%,rgba(0,0,0,0) 30%), url(http://fillmurray.com/1050/1050);
background-size: cover;
background-position: center 30%;
.hamb-wrap {
height: 30px;
width: $hamWidth + 5;
position: absolute;
top: 25px;
left: 25px;
cursor: pointer;
z-index: 2;
}
.hamb {
height: $hamHeight;
width: $hamWidth;
background: #fff;
position: absolute;
top: 10px;
left: 0;
transition: $menuTransition;
border-radius: 10% 10% 10% 10% / 40% 40% 40% 40%;
&:before,
&:after {
content: '';
position: absolute;
background: #fff;
height: $hamHeight;
width: 100%;
transition: $menuTransition;
border-radius: 10% 10% 10% 10% / 50% 50% 50% 50%;
}
&:before {
top: $hamSpacing;
}
&:after {
top: -$hamSpacing;
}
}
.active {
background: none;
transition: $menuTransition;
&:before, &:after {
transition: $menuTransition;
top: 0;
}
&:before {
transform: rotate(45deg);
}
&:after {
transform: rotate(-45deg);
}
}
.logo {
color: white;
font-family: 'Over the Rainbow';
font-size: 1.9em;
margin: 0 0 0 $hamWidth + 50px;
line-height: 2;
}
nav {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
padding-top: 60px;
font-family: 'Raleway';
font-size: 2em;
display: none;
background: rgba(0, 0, 0, 0.8);
ul {
margin: 0 0 0 25px;
padding: 0;
}
li {
list-style-type: none;
margin: 25px 0;
position: relative;
}
a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
}
}
}
.content {
width: 100% - $leftWidth;
min-height: 100%;
margin-left: $leftWidth;
padding: 4em 1.5em;
overflow: hidden;
}
@media (max-width: 768px){
//general
html {
font-size: 18px;
}
//specific
.hero {
height: 350px;
width: 100%;
display: block;
position: relative;
padding: 1px;
nav {
font-size: 1.7em;
}
}
.content {
margin-left: 0;
padding-top: 0;
width: 100%;
}
}
@media(max-width: 480px) {
//reusable classes
img.fl, img.fr {
float: none;
margin: 10px 0;
width: 100%;
height: auto;
}
}
$('.hamb-wrap').on('click', function(){
$(this).parent().children('p').toggle();
$(this).children().toggleClass('active');
$('nav').fadeToggle(200);
})
Also see: Tab Triggers