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-layer
header.bookend
a {
href="https://codepen.io/collection/ABpRqv/" target="_blank"
data-tooltip-text="A side project"
data-tooltip-pos="bottom"}
' mui · Minimalist User Interface
input#toggle-ui type="checkbox" checked=true
label {for="toggle-ui"
data-tooltip-text="Default UI / Dark UI"
data-tooltip-pos="bottom align-right"}
div
svg.icon-light
div
svg.icon-dark
main
.exploder
.component
input#toggle-projection type="checkbox" checked=true
label {
for="toggle-projection"
data-tooltip-text="Explode on hover / Lock normal view"
data-tooltip-pos="top align-left"}
div
svg.icon-iso
div
svg.icon-ortho-lock
.graphics
.viewport
.progress-project
.dates
.start.label Jan 2016
.finish.label Oct 2018
.durations
.to-completion.label 144 wks
.to-date.label wk 104
.bar
.phase.phase-1 data-phase="Phase 1" style="width: 10%" title="More phase info"
.phase.phase-2 data-phase="Phase 2" style="width: 25%" title="More phase info"
.phase.phase-3 data-phase="Phase 3" style="width: 30%" title="More phase info"
.phase.phase-4 data-phase="Phase 4" style="width: 30%" title="More phase info"
.remaining style="padding-left:72%"
.current-state.label.phase-4 style="width:72%" Phase 4
.annotation.left
.note.upward style="bottom:188px;padding-right:36px"
| Theme aware masking border. Psuedo element of .bar below. Mask used on oversized rectangular elements to prevent undesirable anti-aliasing of multiple overlapping elements below
.note.upward style="bottom:101px;padding-right:60px"
| Theme aware phase end dots. Psuedo elements of phases. Key to visualising phase durations in future
.note.upward style="bottom:6px;padding-right:32px"
| Base elements with graphic augmentation on hover (intersecting borders used to make arrows and ticks)
.annotation.right
.note.upward style="bottom:279px;padding-left:30px"
| Absolutely positioned progress remaining element. Left padding via inline style reveals colored progress elements below
.note style="top:99px;padding-left:118px"
| Curved border psuedo element to simulate border-radius on elements below
.note style="top:156px;padding-left:62px"
| Optional phases laid out as flex items of bar element below. Hover triggers psuedo element phase label (using data attribute for content). Hover also hides sibling current phase/state label
.note style="bottom:64px;padding-left:180px"
| box-shadow. Nothing to do with timeline component — just looks nice for isometric
p.title
' Progress bar kit
span.secondary · Project timeline component
footer.bookend
span
span.secondary
a href="https://codepen.io/scootman/pen/yzRqzV" target="_blank" Complete Progress bar kit
// December 2021 update: Chrome no longer likes stacking translateZs :(
// My first serious foray into CSS 3D transforms
// Try in Dark UI mode (toggle top right)
// Also an example of melding several of my WIP UI kits:
// https://codepen.io/collection/ABpRqv/
// Variables
$exploder-viewport-width: 360px;
$exploder-viewport-height: 360px;
$exploder-annotation-width: 180px;
$exploder-viewport-annotation-gap: 16px;
$exploder-component-gap-v:$layout-gap-default;
$exploder-duration: .5s;
// Selectors
main {
align-items:center;
}
.exploder {
display:flex;
flex-wrap:wrap;
justify-content:center;
margin:-($exploder-component-gap-v/2) 0;
padding:0 ($exploder-annotation-width/2 + $exploder-viewport-annotation-gap);
flex:0 100%;
.component {
margin:($exploder-component-gap-v/2) ($exploder-annotation-width/2 + $exploder-viewport-annotation-gap);
flex:0 0 $exploder-viewport-width;
position:relative;
label {
position:absolute;
left:0;
top:0;
z-index:100;
opacity:0;
@include transitionDefault('opacity');
}
}
.component:hover label {
opacity:1;
}
.component:hover input:checked + label {
transition-delay:$exploder-duration + .15s;
}
.graphics {
position:relative;
display:flex;
}
.viewport {
height:$exploder-viewport-height;
flex:1 0px;
order:2;
display:flex;
align-items:center;
justify-content:space-around;
> * {
transition:transform $exploder-duration ease-in-out;
}
}
input:checked ~ .graphics .viewport:hover > *, input:checked + label:hover + .graphics .viewport > * {
transform:rotateX(60deg) rotateZ(-45deg) scale(1.25) translateZ(-96px);
.bar {
transition-delay: .25s;
box-shadow:-40px 40px 40px hsla(0,0,0,.20);
.dark-ui & {
box-shadow:-40px 40px 40px hsla(0,0,0,.7);
}
}
.bar::after {
transform:translateZ(196px);
}
.remaining {
transform:translateZ(128px);
transform-style:preserve-3d;
overflow:visible;
&::before {
transform:translateZ(24px);
}
}
.phase,.current-state {
transform:translateZ(64px);
transform-style:preserve-3d;
}
.phase::after {
transform:translateZ(24px);
box-shadow:0px 0px 5px black;
.dark-ui & {
box-shadow:0px 0px 5px white;
}
}
}
.annotation {
opacity:0;
flex:0 0px;
position:relative;
font-size:14px;
color:$color-secondary;
transition:all .35s ease-in-out;
pointer-events:none;
&.left {
order:1;
.note {
left:-($exploder-annotation-width + $exploder-viewport-annotation-gap);
justify-content:flex-end;
text-align:right;
&::before {
right:0;
left:($exploder-annotation-width + $exploder-viewport-annotation-gap/2);
}
}
}
&.right {
order:3;
.note {
right:-($exploder-annotation-width + $exploder-viewport-annotation-gap);
}
}
}
input:checked ~ .graphics .viewport:hover ~ .annotation, input:checked + label:hover + .graphics .annotation {
opacity:1;
transition-delay:$exploder-duration + .15s;
}
.note {
position:absolute;
box-sizing:content-box;
display:flex;
width:$exploder-annotation-width;
height:1em;
margin-top:-.6em;
line-height:1.2em;
z-index:99;
&.upward {
align-items:flex-end;
&::before {
bottom:0;
}
}
&::before {
content:"";
box-sizing:content-box;
position:absolute;
padding:.6em 0 calc(.6em - 1px);
height:1px;
background-clip:content-box;
background-color:currentColor;
left:0;
right:($exploder-annotation-width + $exploder-viewport-annotation-gap/2);
}
}
}
.progress-project {
width:100%;
transition:transform .5s ease-in-out;
transform-style:preserve-3d;
.phase, .remaining, .current-state {
transition:transform .5s ease-in-out;
}
.bar {
transition:all .25s ease-in-out;
background-image:none;
}
.phase::after, .bar::after {
transition:all .5s ease-in-out;
// 'all' was a happy accident for the ui theme aware elements. Makes a nice effect when you toggle between ui modes
}
}
header {
padding:20px 24px 32px;
}
footer {
padding:32px 24px 20px;
font-size:14px;
}
// UI theme toggle (adds .dark-ui class to .page-layer).
// View projection toggle doesn't use JS - it relies on the :checked psuedo class
$('#toggle-ui').click(function() {
$('.page-layer').toggleClass( "dark-ui" )
});
// SVGInjector2 for insertion of SVG icon assets
(function(window, document){
// Options
var injectorOptions = {
evalScripts: 'once',
spritesheetURL: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/436544/mui-assets.svg',
spriteClassIdName: 'icon-'
};
// Setup the injector
var injector = new SVGInjector(injectorOptions);
// inject single svg
injector.inject(document.querySelectorAll('svg[data-src]'));
// inject svgs from spritesheets
injector.inject(document.querySelectorAll('svg[class^=icon-]'));
})(window, document);
Also see: Tab Triggers