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="page">
<span class="menu_toggle">
<i class="menu_open fa fa-bars fa-lg"></i>
<i class="menu_close fa fa-times fa-lg"></i>
</span>
<ul class="menu_items">
<li><a href="#"><i class="icon fa fa-signal fa-2x"></i> Moar</a></li>
<li><a href="#"><i class="icon fa fa-coffee fa-2x"></i> Coffee</a></li>
<li><a href="#"><i class="icon fa fa-heart fa-2x"></i> Please</a></li>
</ul>
<main class="content">
<div class="content_inner">
<h1>The mysterious red button of doom</h1>
<p>Do <strong>not</strong> push that big, red button in the corner. People will die. You have been warned. Do… not do it.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel dolorem, ducimus laudantium, earum eos natus sint voluptatum dolores fuga quibusdam consectetur dicta. Laudantium enim inventore iusto ducimus est velit aperiam tempora quibusdam id dolore natus perferendis, debitis distinctio optio repellendus, repellat molestias delectus harum eius, reiciendis dicta ipsum architecto! Eligendi expedita in beatae, placeat unde voluptatibus voluptates consectetur explicabo laudantium, officiis ad nihil. Beatae similique voluptate sequi voluptatem delectus iure in omnis, fuga ipsam nulla ipsum architecto, iste debitis nisi labore quisquam odio accusantium corporis sint perspiciatis. Excepturi earum nobis soluta, doloremque nihil dolorum illum quaerat magnam nemo non sed!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel dolorem, ducimus laudantium, earum eos natus sint voluptatum dolores fuga quibusdam consectetur dicta. Laudantium enim inventore iusto ducimus est velit aperiam tempora quibusdam id dolore natus perferendis, debitis distinctio optio repellendus, repellat molestias delectus harum eius, reiciendis dicta ipsum architecto! Eligendi expedita in beatae, placeat unde voluptatibus voluptates consectetur explicabo laudantium, officiis ad nihil. Beatae similique voluptate sequi voluptatem delectus iure in omnis, fuga ipsam nulla ipsum architecto, iste debitis nisi labore quisquam odio accusantium corporis sint perspiciatis. Excepturi earum nobis soluta, doloremque nihil dolorum illum quaerat magnam nemo non sed!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel dolorem, ducimus laudantium, earum eos natus sint voluptatum dolores fuga quibusdam consectetur dicta. Laudantium enim inventore iusto ducimus est velit aperiam tempora quibusdam id dolore natus perferendis, debitis distinctio optio repellendus, repellat molestias delectus harum eius, reiciendis dicta ipsum architecto! Eligendi expedita in beatae, placeat unde voluptatibus voluptates consectetur explicabo laudantium, officiis ad nihil. Beatae similique voluptate sequi voluptatem delectus iure in omnis, fuga ipsam nulla ipsum architecto, iste debitis nisi labore quisquam odio accusantium corporis sint perspiciatis. Excepturi earum nobis soluta, doloremque nihil dolorum illum quaerat magnam nemo non sed!</p>
</div>
</main>
</div>
$red: #F37272;
$brown: #584E4A;
$whitey: #f0f0f0;
$snap: cubic-bezier(1.000, 0.005, 0.240, 1.000);
$bounce: cubic-bezier(0.175, 0.885, 0.320, 1.275);
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
overflow: hidden;
}
.page {
height: 100%;
background-color: $brown;
}
.content {
// essential
height: 200%; // make higher or you'll see background when rotated
transform-origin: top left;
transition: transform .7s $snap;
// styling
background-color: $whitey;
}
.content_inner {
// essential
height: 50%; // compensate for higher .content
overflow-y: auto; // set expected overflow
// styling
padding: 50px 20%;
}
/* basically all styling from now on */
.menu_toggle {
z-index: 900;
position: fixed;
top: 0;
left: 0;
display: block;
cursor: pointer;
width: 100px;
height: 80px;
background-color: $red;
border-bottom-right-radius: 100%;
&:active {
i {
opacity: 0.8
}
}
i {
color: $whitey;
}
.menu_open,
.menu_close {
position: absolute;
top: 50%;
left: 50%;
margin-top: -15px;
margin-left: -12px;
transition: transform .7s $snap;
}
.menu_open {
transform-origin: -100px -100px;
}
.menu_close {
transform: rotate(20deg);
transform-origin: -100px -160px;
}
}
.menu_items {
position: fixed;
bottom: 0;
left: 50px;
list-style-type: none;
margin: 0;
padding: 0;
li {
height: 60px;
margin-bottom: 30px;
transform: translateX(-300px);
transition: transform .7s 0s $snap;
&:nth-child(2){
margin-left: 40px;
}
&:nth-child(3){
margin-left: 80px;
}
}
a {
display: block;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 2px;
color: darken($whitey, 30%);
transition: color .2s;
.icon {
position: relative;
display: inline-block;
margin-right: 25px;
color: $whitey;
&:after {
position: absolute;
top: 50%;
left: 50%;
content: '';
display: block;
width: 60px;
height: 60px;
margin-left: -33px;
margin-top: -32px;
border-radius: 100%;
border: 2px solid $whitey;
transition: border-color .2s;
}
}
&:hover {
color: $whitey;
.icon {
&:after {
border-color: $red;
}
}
}
&:active {
.icon {
color: $red;
}
}
}
}
/* Let's open up the menu */
.shazam {
.content {
transform: rotate(-30deg);
}
// this will show hidden content overflow when rotated,
// but will result in a jump, if you've already scrolled down the content
// plus, you will lose your current reading position
// fixable with JS, not gonna bother
/*.content_inner {
height: 100%;
}*/
.menu_open {
transform: rotate(-20deg);
}
.menu_close {
transform: rotate(0);
}
.menu_items {
li {
transform: translateX(0);
transition: transform .35s .45s $bounce;
&:nth-child(2){
transition-delay: .47s;
}
&:nth-child(3){
transition-delay: .48s;
}
}
}
}
// misc
h1 {
padding-bottom: 15px;
border-bottom: 1px solid #ddd;
}
body {
color: $brown;
}
// elements
var $page = $('.page');
$('.menu_toggle').on('click', function(){
$page.toggleClass('shazam');
});
$('.content').on('click', function(){
$page.removeClass('shazam');
});
Also see: Tab Triggers