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.
#page-main.fullscreen
.header
h2 Page 1 (main)
.content
table.table.table-align-middle
tbody
tr
td Item title
td.table-actions-column
a.btn.btn-default(href="#", class="to-sub-page") →
tr
td Item title
td.table-actions-column
a.btn.btn-default(href="#", class="to-sub-page") →
tr
td Item title
td.table-actions-column
a.btn.btn-default(href="#", class="to-sub-page") →
.btn-toolbar
a.btn.btn-default(href="#", id="to-modal") Show modal
a.btn.btn-default(href="#", id="toggle-toolbar") Toggle toolbar
#page-sub.fullscreen
.header
.btn-toolbar
a.btn.btn-default(href="#", id="to-main-page") ←
h2 Page 2 (sub)
.content
p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit sapiente tenetur illo, quas blanditiis perferendis veniam sunt, quaerat nisi officia id odio tempore architecto, reprehenderit sit. Similique, ratione corporis aliquid.
table.table.table-align-middle
tbody
tr
td Item
td.table-actions-column
a.btn.btn-default(href="#", class="to-sub-sub-page") →
tr
td Item
td.table-actions-column
a.btn.btn-default(href="#", class="to-sub-sub-page") →
tr
td Item
td.table-actions-column
a.btn.btn-default(href="#", class="to-sub-sub-page") →
#page-sub-sub.fullscreen
.header
.btn-toolbar
a.btn.btn-default(href="#", id="to-sub-page") ←
h2 Page 3 (sub sub)
.content
p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit sapiente tenetur illo, quas blanditiis perferendis veniam sunt, quaerat nisi officia id odio tempore architecto, reprehenderit sit. Similique, ratione corporis aliquid.
p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit sapiente tenetur illo, quas blanditiis perferendis veniam sunt, quaerat nisi officia id odio tempore architecto, reprehenderit sit. Similique, ratione corporis aliquid.
#toolbar.is-inverse.is-inverse-bg-dark
.btn-toolbar.pull-left
.btn-group.pull-left
a.btn.btn-ghost-inverse(href="#")
i.glyphicon.glyphicon-star
a.btn.btn-ghost-inverse(href="#")
i.glyphicon.glyphicon-heart
.btn-group.pull-left
a.btn.btn-ghost-inverse(href="#") Control 1
a.btn.btn-ghost-inverse(href="#") Control 2
.btn-toolbar.pull-left
a.btn.btn-ghost-inverse(href="#") Control 1
a.btn.btn-ghost-inverse(href="#") Control 2
.btn-toolbar.pull-right
a.btn.btn-ghost-inverse(href="#", id="close-toolbar") ×
#modal.fullscreen.is-inverse.is-inverse-bg
.header
.btn-toolbar
a.btn.btn-ghost-inverse(href="#", id="close-modal") ×
h2 Modal
.content
p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore vero sint magnam, nemo earum, tempore fuga delectus officia voluptatum quidem. Quaerat autem pariatur expedita, consequuntur laborum recusandae ducimus blanditiis nobis!
table.table
thead
tr
th Name(s)
th Scope
th Description
tbody
tr
td Land plants, also known as Embryophyta or Metaphyta.
td Plantae sensu strictissimo
td
| This group includes the liverworts, hornworts, mosses, and vascular plants, as well...
tr
td Green plants - also known as Viridiplantae, Viridiphyta or Chlorobionta
td Plantae sensu stricto
td
| This group includes the land plants plus various groups of green algae, including stoneworts.
tr
td Archaeplastida, Plastida or Primoplantae
td Plantae sensu lato
td
| This group comprises the green plants above plus Rhodophyta (red algae) and Glaucophyta...
*, *:before, *:after {
box-sizing: border-box;
}
body,
html {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
}
.fullscreen {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
#page-main {
background: #EEE;
}
#page-sub {
background: #EEE;
}
#page-sub-sub {
background: #EEE;
}
#modal {
top: 100vh;
}
#toolbar {
background: #333;
width: 100vw;
height: auto;
padding: 20px;
position: fixed;
bottom: -100%;
}
.is-inverse-bg {
background: #666;
}
.is-inverse {
color: #DDD;
h1, h2, h3 {
color: #FFF;
}
table.table th {
color: #FFF;
}
}
// Table styles
.table.table-align-middle tbody {
td, th {
vertical-align: middle;
// Some extra specifity to override Bootstrap
}
}
// Table column styles
.table-actions-column {
text-align: right;
.btn {
float: right;
}
}
// Button styles
.btn.btn-ghost-inverse {
color: #FFF;
background: rgba(255, 255, 255, 0.1);
border-color: rgba(255, 255, 255, 0.3);
&:hover,
&:active,
&:focus {
background: rgba(255, 255, 255, 0.33);
border-color: rgba(255, 255, 255, 1)
}
}
.btn.btn-ghost {
background: rgba(0, 0, 0, 0.1);
border-color: rgba(0, 0, 0, 0.3);
&:hover,
&:active,
&:focus {
background: rgba(0, 0, 0, 0.3);
border-color: rgba(0, 0, 0, 1)
}
}
.header {
height: 50px;
background: #FFF;
box-shadow: 0 0 3px rgba(0,0,0,0.25);
.is-inverse & {
background: #000;
}
}
// Header positioning
.header .btn-toolbar {
position: absolute;
top: 9px;
left: 9px;
z-index: 10;
}
.header h2 {
font-size: 20px;
text-align: center;
line-height: 50px;
margin: 0;
position: absolute;
left: 0;
right: 0;
width: 100%;
}
.content {
padding: 15px;
}
// Hide initial elements
// @todo be able to open the pages in this "state"
$('#page-sub, #page-sub-sub, #toolbar').hide();
// Show modal
$('#page-main #to-modal.btn').click(function(e) {
e.preventDefault();
$("#modal").velocity({
top: "0",
}, {
duration: 300,
easing: "ease-in"
});
});
// Toggle the toolbar
$('#page-main #toggle-toolbar.btn').click(function(e) {
e.preventDefault();
$('#toolbar').show();
if (!$("#toolbar").hasClass('open')) {
$("#toolbar")
.addClass('open')
.velocity({
bottom: "0",
}, {
duration: 300,
easing: "ease-in-out"
});
} else {
$("#toolbar")
.removeClass('open')
.velocity({
bottom: "-100%",
}, {
duration: 300,
easing: "ease-in-out"
});
}
});
// Go from sub page to main page
$('#page-sub #to-main-page').click(function(e) {
e.preventDefault();
$("#page-sub").velocity({
right: "-100vw",
}, {
duration: 300,
easing: "ease-in-out"
});
});
// Go from main page to sub page
$('#page-main .to-sub-page.btn').click(function(e) {
e.preventDefault();
$("#page-sub").css('left', "auto").css('right', "-100vw").show().velocity({
right: "0",
}, {
duration: 300,
easing: "ease-in-out"
});
});
// Go from main page to sub page
$('#to-sub-page.btn').click(function(e) {
e.preventDefault();
$("#page-sub-sub").css('left', "auto").css('right', "0").show().velocity({
right: "-100%",
}, {
duration: 300,
easing: "ease-in-out"
});
});
// Go from sub page to sub sub page
$('#page-sub .to-sub-sub-page.btn').click(function(e) {
e.preventDefault();
$("#page-sub-sub").css('left', "auto").css('right', "-100vw").show().velocity({
right: "0",
}, {
duration: 300,
easing: "ease-in-out"
});
});
// Close the toolbar
$('#close-toolbar.btn').click(function(e) {
e.preventDefault();
$("#toolbar").velocity({
bottom: "-100%",
}, {
duration: 300,
easing: "ease-in-out"
});
$("#toolbar").removeClass('open');
});
// Close modal
$('#modal #close-modal').click(function(e) {
e.preventDefault();
$("#modal").velocity({
top: "100vh",
}, {
duration: 300,
easing: "ease-in-out"
});
});
Also see: Tab Triggers