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.
<main>
<input id="home" type="radio" name="menu" checked="checked"/>
<section>
<h3>JavaScript</h3>
<h1>free</h1>
<h4>off-canvas</h4>
<h2>menu</h2>
</section>
<input id="how" type="radio" name="menu"/>
<section>
<article>
<span><h3>But how?!</h3></span>
<span><h1>radio<br/>buttons.</h1></span>
<span><h4>honestly<br/>they're</h4> <h2>everywhere</h2></span>
<span><h5>It turns out that </h5> <h6>a radio input's</h6> <h4> label will</h4></span>
<span><p><b>still</b> check it off</p> <h5>even when there's</h5> <p><b>no <u><s>common</s></u> parent.</b></p></span>
<span><h2>- all YOU</h2> <h1>need</h1> <h4>to<br/>do</h4></span>
<span><p>is place the <em>input</em></p> <p><b>immediately before</b></p> <p>its corresponding section.</p></span>
<span><h2>CSS</h2> <h1>+</h1> <h4>selector takes care<br/><b>of the <u>rest</u></b>.</h4></span>
</article>
</section>
<input id="why" type="radio" name="menu"/>
<section>
<article>
<span><h3>But why!?</h3></span>
<span><h1>mostly</h1> <h2>just</h2> <h4>for<br/>fun.</h4></span>
<span><h4>besides keeping me<br/>busy last weekend</h4> <h2>it offers</h2></span>
<span><h6>benefits <b>including</b></h6> <h4>(but not limited to)</h4></span>
<span><h1>stability</h1></span>
<span> <h2>portability</h2></span>
<span><h1>&</h1> <p><em><u>versatilit</u>y.</em></p></span>
</article>
</section>
<input id="semantics" type="radio" name="menu"/>
<section>
<article>
<span><h3>But semantics!!</h3></span>
<span><h2>oh...</h2> <h1>yeah...</h1> <h4><em>about<br/>that...</em></h4></span>
<span><h5><em>Holy cow!</em></h5> <h4> Check out this </h4> <h3><b>amazing</b></h3></span>
<span><h6><em>svg path </em> <u><s>animation</s></u></h6> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 320"><g><path class="orange" d="m320.332 174.25c0 0 53.59 105.839 162.621 105.608 145.539-.309 141.489-239.6394-4.525-239.853-130.462-.1909-169.6 234.495-300.193 239.853-172.94203 7.095-167.6333-237.2565-4.526-239.853 101.036-1.6084 146.623 134.245 146.623 134.245" fill="none" stroke="#f7b37f" stroke-linecap="miter" stroke-width="60" stroke-miterlimit="2"/><path class="white" d="m320.332 174.25c0 0 53.59 105.839 162.621 105.608 145.539-.309 141.489-239.6394-4.525-239.853-130.462-.1909-169.6 234.495-300.193 239.853-172.94203 7.095-167.6333-237.2565-4.526-239.853 101.036-1.6084 146.623 134.245 146.623 134.245" fill="none" stroke="#fff" stroke-linecap="miter" stroke-width="60" stroke-miterlimit="2"/><path class="black" d="m320.332 174.25c0 0 53.59 105.839 162.621 105.608 145.539-.309 141.489-239.6394-4.525-239.853-130.462-.1909-169.6 234.495-300.193 239.853-172.94203 7.095-167.6333-237.2565-4.526-239.853 101.036-1.6084 146.623 134.245 146.623 134.245" fill="none" stroke="#3f3f37" stroke-linecap="miter" stroke-width="63" stroke-miterlimit="2"/></g></svg></span>
<p>(ps. Still no JavaScript)</p>
</article>
</section>
<input id="udy" type="radio" name="menu"/>
<section>
<article>
<span><h3>Who's Udy??</h3></span>
<span><h2>That's me!</h2></span>
<span><h2><u><s>I'm</s></u> a</h2> <h5><s>front–end</s><br/><em>developer</em></h5></span>
<span><h1>from</h1> <h4><u><b>Québec</b></u><br/>Canada</h4> <h2>who</h2></span>
<span><h2>(</h2> <h4>now quite<br/>ironically</h4> <h2>)</h2> <h5>likes to spend his time<br/><b>writing</b> <u><s>JavaScript</s></u></h5></span>
<span><h4>check out <b>my</b></h4> <h6><a href="https://codepen.io/udyux/" target="_blank"><s>profile</s></a></h6> <u><h5>for more pens.</h5></u></span>
</article>
</section>
<label for="menu">menu</label>
<input type="radio" name="menu" id="menu"/>
<menu>
<nav>
<label for="home">jsfocm!</label>
<label for="how">but how?!</label>
<label for="why">but why!?</label>
<label for="semantics">but semantics!!</label>
<label for="udy">who's udy??</label>
</nav>
</menu>
</main>
/* RADIO-MENU STUFF
∞∞ STARTS HERE ∞∞
*/
body {background-image: linear-gradient(to bottom right, #ba532e, #ff934c 90%)}
main {
width: 100%;
height: 100%;
color: white;
font-weight: 300;
input[name='menu'] {display: none}
}
/* sections *//* keep them off canvas */
section {
transition: bottom 0ms linear 900ms, opacity 900ms cubic-bezier(.4,.25,.3,1);
width: 100%;
height: 100%;
position: absolute;
bottom: 100%;
left: 0;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
opacity: 0;
overflow-x: hidden;
overflow-y: scroll;
&:first-of-type {justify-content: center}
article {
min-height: 740px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
span {
width: 100%;
display: flex;
justify-content: space-between;
align-items: flex-end;
white-space: nowrap;
}
}
}
/* menu *//* this goes off canvas as well */
menu {
transition: bottom 0ms linear 1000ms, background-color 1000ms cubic-bezier(.4,.25,.3,1);
width: 100vw;
height: 100vh;
position: fixed;
bottom: 100%;
left: 0;
color: #3f3f37;
background-color: hsla(0,0%,100%,0);
nav {
transition: all 500ms cubic-bezier(.4,.25,.3,1) 250ms;
width: 100%;
height: 250%;
position: absolute;
bottom: 100%;
left: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
font-size: .5rem;
label {
line-height: 40px;
text-transform: uppercase;
cursor: pointer;
&::before,
&::after {
content: '';
transition: all 300ms cubic-bezier(.4,.25,.3,1);
width: 100%;
height: 2px;
position: absolute;
left: 0;
background-color: #f7b37f;
opacity: 0;
}
&::before {top: -.5rem}
&::after {bottom: -.5rem}
&:hover::before,
&:hover::after {opacity: 1}
&:hover::before {top: 0}
&:hover::after {bottom: 0}
}
}
}
/* menu button */
label[for='menu'] {
transition: opacity 300ms cubic-bezier(.4,.25,.3,1) 900ms;
display: inline-block;
position: fixed;
top: 30px;
left: 100px;
line-height: 40px;
font-size: 1.3rem;
font-weight: 900;
text-transform: uppercase;
cursor: pointer;
&::before,
&::after {
content: '';
transition: all 300ms cubic-bezier(.4,.25,.3,1);
width: 100%;
height: 2px;
position: absolute;
left: 0;
background-color: white;
}
&::before {top: 0}
&::after {bottom: 0}
&:hover::before {top: -.25rem}
&:hover::after {bottom: -.25rem}
}
/* menu toggle *//* click the label > checks the radio > toggles the menu */
#menu:checked + menu {
transition: background-color 800ms cubic-bezier(.4,.25,.3,1);
bottom: 0;
background-color: hsla(0,0%,100%,1);
nav {
transition: all 500ms cubic-bezier(.4,.25,.3,1) 250ms;
height: 70%;
bottom: 15%;
font-size: 1.7rem;
}
}
/* section change *//* click the label > check the radio > change the section */
input[name="menu"]:checked + section {
transition: opacity 900ms cubic-bezier(.4,.25,.3,1);
bottom: 0;
opacity: 1;
}
/* RADIO-MENU STUFF
∞∞ ENDS HERE ∞∞
*/
/* the rest is just content */
h1,
h2,
h3,
h4,
h5,
em,
p,
b {font-weight: 900}
h1,
h4,
h6,
b {text-transform: uppercase}
h2,
h6,
b {color: #3f3f37}
h1,
h5 {color: #f7b37f}
h5,
h6 {font-size: 2.2rem}
em {font-size: 1.2em}
h1 {font-size: 6.9rem}
h2 {font-size: 6.4rem}
h4 {font-size: 2.45rem}
p {font-size: 1.5rem}
h3 {
font-size: 3.25rem;
text-decoration: underline;
}
s {
text-decoration: none;
color: white;
font-size: 1.1em;
}
/* landing */
section:first-of-type {
h1 {margin-top: -12px}
h2 {margin-top: -38px}
h4 {margin-top: -5px;
&::after {
content: '';
width: 100%;
height: 4px;
position: absolute;
top: 0;
left: 0;
background-color: white;
}
}
}
/* how */
section:nth-of-type(2) {
h4 {margin-bottom: -2px}
span:nth-child(2) h1 {
margin-left: -5px;
line-height: .79;
&::after {
content: '';
width: 99%;
height: 4px;
position: absolute;
bottom: -10px;
left: 5px;
background-color: white;
}
}
span:nth-child(3) {
margin: -20px 0 15px;
h2 {margin-bottom: 13px}
h4 {
margin-bottom: 20px;
line-height: .79;
}
}
span:nth-child(5) {
margin-bottom: 35px;
h5 {margin-bottom: -2px}
}
span:nth-child(6) {
margin: -10px 0 5px;
h4 {margin-bottom: 13px}
}
span:nth-last-child(2) {margin-top: -13px}
span:last-child {
margin-top: -15px;
h4 {margin-bottom: 10px}
}
}
/* why */
section:nth-of-type(3) {
h1,
h4,
h5 {line-height: .79}
h1 {margin-left: -5px}
h2 {margin-bottom: -10px}
h5 {margin-bottom: 5px}
h6 {margin: 0 0 -2px -3px}
span:nth-child(3) {margin-top: -13px}
span:nth-child(4) {margin-top: 15px}
span:nth-child(5) {
margin-top: 20px;
h1::after {
content: '';
width: 100%;
height: 3px;
position: absolute;
top: -3px;
left: 0;
background-color: white;
}
}
span:nth-child(6) {margin-top: -25px}
span:last-child {
margin: -20px -28px 0 0;
justify-content: center;
p {
margin: 0 0 -3px -3px;
font-size: 3.8rem;
}
}
}
/* semantics */
section:nth-of-type(4) {
span:first-child {margin-bottom: -10px}
h1 {margin-left: -30px}
span:nth-child(2) h4 {
margin-bottom: 8px;
line-height: .9;
}
span:last-of-type h6 {transform: translateY(-125%)}
p:last-child {margin-right: 30px}
svg {
width: 300px;
height: auto;
margin-top: 20px;
path {
animation-play-state: paused;
&.black {
animation: draw 5s cubic-bezier(.4,.25,.3,1) infinite;
stroke-dashoffset: 0;
stroke-dasharray: 1569.27294921875;
}
&.orange {
animation: pathA 20s linear infinite;
opacity: 0;
}
&.white {
animation: pathB 20s linear infinite;
opacity: 0;
}
}
}
}
input[name="menu"]:checked + section path {animation-play-state: running}
/* udy */
section:last-of-type {
span:nth-child(3){
margin-top: -15px;
h2 {margin-left: 8px}
h5 {
margin: 0 240px 10px 0;
line-height: .8;
}
}
span:nth-child(4) {
h4 {
margin: 0 0 7px 15px;
line-height: 1.2;
}
}
span:nth-child(6) {
margin-top: 35px;
u {margin-bottom: 4px}
}
}
/* animations */
@keyframes draw {
0% {stroke-dashoffset: 0}
100% {stroke-dashoffset: 3138.54589844}
}
@keyframes pathA {
0% {opacity: 0}
24% {opacity: 0}
25% {opacity: 1}
99% {opacity: 1}
100% {opacity: 0}
}
@keyframes pathB {
0% {opacity: 0}
49% {opacity: 0}
50% {opacity: 1}
74% {opacity: 1}
75% {opacity: 0}
100% {opacity: 0}
}
// 404? Nope, just nothing here.
Also see: Tab Triggers