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.
nav
ul
li#link-one
div 1
div One
li#link-two
div 2
div Two
li#link-three
div 3
div Three
li#link-four
div 4
div Four
li#link-five
div 5
div Five
#one.desktop
h1 Desktop System with Sidebar
p This is the desktop 1
p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vestibulum sem elit, vitae rutrum leo euismod vitae. Aliquam accumsan quam sit amet ultrices rhoncus. Proin diam diam, pellentesque et felis in, aliquam lacinia mauris. Sed euismod ipsum in feugiat sollicitudin. Praesent vel odio placerat, vehicula sapien eu, pellentesque dui. Praesent convallis augue non tristique lacinia. Quisque eu vulputate sem, vel commodo nisi. Nunc ullamcorper velit quis diam vulputate adipiscing. Mauris congue rhoncus fringilla. Phasellus porttitor purus neque, porttitor posuere nisl dictum eget. Duis pharetra augue leo, at sodales ipsum congue eu. Vestibulum eu justo erat. Nullam tempor varius mi, id placerat nisl pellentesque at. Quisque lacinia, nibh at viverra molestie, augue nunc commodo enim, euismod adipiscing eros mi nec nisl.
#two.desktop
h1 Desktop Two
p This is the desktop 2
p Sed egestas augue vitae enim elementum scelerisque. Morbi fermentum, ipsum sed vestibulum iaculis, diam tellus convallis nisi, in aliquam magna nisi quis felis. Quisque ac orci diam. Donec scelerisque lobortis scelerisque. Duis in tortor eget erat interdum mollis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse suscipit, libero placerat adipiscing molestie, neque velit fringilla mauris, vitae ultrices lectus est non magna. Integer ultrices erat id massa porta, quis sagittis elit ornare. Praesent mollis sit amet dolor ac dignissim. Sed sed adipiscing dolor. Curabitur lacus ipsum, lacinia eu orci vitae, lobortis eleifend lorem. Duis molestie neque in lacinia consequat. Suspendisse pretium malesuada odio, in euismod tortor convallis bibendum.
#three.desktop
h1 Desktop Three
p This is the desktop 3
p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vestibulum sem elit, vitae rutrum leo euismod vitae. Aliquam accumsan quam sit amet ultrices rhoncus. Proin diam diam, pellentesque et felis in, aliquam lacinia mauris. Sed euismod ipsum in feugiat sollicitudin. Praesent vel odio placerat, vehicula sapien eu, pellentesque dui. Praesent convallis augue non tristique lacinia. Quisque eu vulputate sem, vel commodo nisi. Nunc ullamcorper velit quis diam vulputate adipiscing. Mauris congue rhoncus fringilla. Phasellus porttitor purus neque, porttitor posuere nisl dictum eget. Duis pharetra augue leo, at sodales ipsum congue eu. Vestibulum eu justo erat. Nullam tempor varius mi, id placerat nisl pellentesque at. Quisque lacinia, nibh at viverra molestie, augue nunc commodo enim, euismod adipiscing eros mi nec nisl.
#four.desktop
h1 Desktop Four
p This is the desktop 4
p Sed egestas augue vitae enim elementum scelerisque. Morbi fermentum, ipsum sed vestibulum iaculis, diam tellus convallis nisi, in aliquam magna nisi quis felis. Quisque ac orci diam. Donec scelerisque lobortis scelerisque. Duis in tortor eget erat interdum mollis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse suscipit, libero placerat adipiscing molestie, neque velit fringilla mauris, vitae ultrices lectus est non magna. Integer ultrices erat id massa porta, quis sagittis elit ornare. Praesent mollis sit amet dolor ac dignissim. Sed sed adipiscing dolor. Curabitur lacus ipsum, lacinia eu orci vitae, lobortis eleifend lorem. Duis molestie neque in lacinia consequat. Suspendisse pretium malesuada odio, in euismod tortor convallis bibendum.
#five.desktop
h1 Desktop Five
p This is the desktop 5
p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vestibulum sem elit, vitae rutrum leo euismod vitae. Aliquam accumsan quam sit amet ultrices rhoncus. Proin diam diam, pellentesque et felis in, aliquam lacinia mauris. Sed euismod ipsum in feugiat sollicitudin. Praesent vel odio placerat, vehicula sapien eu, pellentesque dui. Praesent convallis augue non tristique lacinia. Quisque eu vulputate sem, vel commodo nisi. Nunc ullamcorper velit quis diam vulputate adipiscing. Mauris congue rhoncus fringilla. Phasellus porttitor purus neque, porttitor posuere nisl dictum eget. Duis pharetra augue leo, at sodales ipsum congue eu. Vestibulum eu justo erat. Nullam tempor varius mi, id placerat nisl pellentesque at. Quisque lacinia, nibh at viverra molestie, augue nunc commodo enim, euismod adipiscing eros mi nec nisl.
@import url(https://fonts.googleapis.com/css?family=Quicksand:400,300);
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300);
*, *:before, *:after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
width: 100%;
color: white;
font-size: 18px;
font-weight: 400;
font-family: 'Quicksand', 'Open Sans', 'Helvetica Neue', 'Helvetica', sans-serif;
background: radial-gradient(ellipse at bottom left, rgba(104,128,138,0.4) 10%, rgba(138,114,76,0) 40%), linear-gradient(to bottom, rgba(57,173,219,.25), rgba(42,60,87,0.4)), linear-gradient(135deg, #670d10, #092756);
}
// SIDEBAR
$navW: 3.5rem;
$navColor: #2680F3;
nav {
position: absolute;
top: 0;
left: 0;
width: $navW;
height: 100%;
background: $navColor;
transition: all 300ms ease;
overflow: hidden;
z-index: 1;
box-shadow: 0px 0px 10px #333;
// SIDEBAR EXPAND
&:hover {
width: $navW * 4;
}
* {
user-select: none;
}
// SIDEBAR MENU
> ul {
display: table;
width: $navW * 4;
// SIDEBAR MENU ITEM
> li {
display: table-row;
background: darken($navColor, 10%);
cursor: pointer;
&:hover {
background: lighten($navColor, 10%);
}
&:active {
background: lighten($navColor, 20%);
}
> div {
height: $navW;
line-height: $navW;
display: table-cell;
// ICON
&:nth-child(1) {
width: $navW;
text-align: center;
}
// DESCRIPTION
&:nth-child(2) {
width: $navW * 3;
text-align: left;
padding-left: $navW / 5;
}
}
}
}
}
// DESKTOP
.desktop {
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
padding: 1rem 1rem 1rem $navW + 1rem;
transition: all 500ms ease;
overflow: auto;
// INSIDE STYLING
h1 {
margin: 1rem 0;
font-weight: 300;
&:nth-child(1) {
margin-top: 0;
}
}
p {
font-weight: 300;
text-align: justify;
margin: 0 0 1rem 0;
}
}
#one {
background: radial-gradient(ellipse at bottom left, rgba(104,128,138,0.4) 10%, rgba(138,114,76,0) 40%), linear-gradient(to bottom, rgba(57,173,219,.25), rgba(42,60,87,0.4)), linear-gradient(135deg, #670d10, #092756);
}
#two {
background: linear-gradient(135deg, #723362, #9d223c);
}
#three {
background: linear-gradient(135deg, #2c539e, #63967d);
}
#four {
background: linear-gradient(135deg, rgba(244,226,156,0) 0%,rgba(59,41,58,1) 100%), linear-gradient(to right, rgba(244,226,156,1) 0%,rgba(130,96,87,1) 100%);
}
#five {
background: linear-gradient(45deg, rgba(194, 233, 221, 0.5) 1%, rgba(104, 119, 132, 0.5) 100%), linear-gradient(-45deg, #494d71 0%, rgba(217, 230, 185, 0.5) 80%);
}
var desktops = document.querySelectorAll('.desktop');
function hide(element) {
element.style.setProperty('left', '-100%', element.style.getPropertyPriority('left'));
}
function hideAll() {
for (var i = 0; i < desktops.length; i++) {
hide(desktops[i]);
}
}
function show(element) {
element.style.setProperty('left', '0', element.style.getPropertyPriority('left'));
}
document.getElementById('link-one').addEventListener('click', function () {
hideAll();
show(document.getElementById('one'));
}, false);
document.getElementById('link-two').addEventListener('click', function () {
hideAll();
show(document.getElementById('two'));
}, false);
document.getElementById('link-three').addEventListener('click', function () {
hideAll();
show(document.getElementById('three'));
}, false);
document.getElementById('link-four').addEventListener('click', function () {
hideAll();
show(document.getElementById('four'));
}, false);
document.getElementById('link-five').addEventListener('click', function () {
hideAll();
show(document.getElementById('five'));
}, false);
show(document.getElementById('one'));
Also see: Tab Triggers