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.
<!-- stroke-dasharray="25.382" stroke-dashoffset="12.691" -->
<svg width="256" height="320" viewBox="0 0 64 80">
<defs>
<!-- for better example: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/clipPath -->
<clipPath id="letter-s">
<path transform="translate(16, 0)" d="M56,0 L24,0 C24,0 0,0 0,24 C0,48 24,48 24,48 L32,48 C32,48 40,48 40,56 C40,64 32,64 32,64 L0,64 L0,80 L32,80 C32,80 56,80 56,56 C56,32 32,32 32,32 L24,32 C24,32 16,32 16,24 C16,16 24,16 24,16 L56,16 L56,0 Z"/>
</clipPath>
</defs>
<g class="circle">
<!-- we use negative (x, y) coords so that the center of the rect is at (0, 0) so that when we rotate it's rotated at it's center. Also, so that the center is on the path -->
<rect x="-8" y="-8" rx="8" ry="8" width="16" height="16" style="stroke-dasharray: 49.94157791137695;stroke-dashoffset: 49.94157791137695;transform:rotate(90deg);"/>
</g>
<!-- add .001 to third C to fix firefox path issue -->
<path d="M0,72 L48,72 C48,72 64,72 64,56 C64,40 48,40 48,40 L40,40 C40.001,40.001 24.001,40.001 24.001,24.001 C24.001,8.001 40.001,8.001 40.001,8.001 L64,8 " class="path" />
<!-- <rect x="16" y="48" height="32" width="56" stroke="red" clip-path="url(#letter-s)" class="red" /> -->
<path d="M16,80 L72,80" stroke="#00FEEF" stroke-width="0" class="stripe red" clip-path="url(#letter-s)"/>
<path d="M16,80 L72,80" stroke="#09EBEE" stroke-width="0" class="stripe orange" clip-path="url(#letter-s)"/>
<path d="M16,80 L72,80" stroke="#19CEEB" stroke-width="0" class="stripe yellow" clip-path="url(#letter-s)"/>
<path d="M16,80 L72,80" stroke="#28ACEA" stroke-width="0" class="stripe green" clip-path="url(#letter-s)"/>
<path d="M16,80 L72,80" stroke="#388EE9" stroke-width="0" class="stripe blue" clip-path="url(#letter-s)"/>
<path d="M16,80 L72,80" stroke="#3D76E0" stroke-width="0" class="stripe purple" clip-path="url(#letter-s)"/>
<g class="letter" id="#letter-s">
<path d="M16,72 L16,64 L48,64 " class="first"/>
<path d="M16,72 L16,80 L48,80 " class="first"/>
<path d="M48,64 C48,64 56,64 56,56 C56,48 48,48 48,48 " class="second"/>
<path d="M48,80 C48,80 72,80 72,56 C72,32 48,32 48,32 " class="second"/>
<path d="M48,32 L40,32 " class="third"/>
<path d="M48,48 L40,48 " class="third"/>
<path d="M40,32 C40.001,32.001 32.001,32.001 32.001,24.001 C32,16 40,16 40,16 " class="fourth"/>
<path d="M40,48 C40.001,48.001 16.001,48.001 16.001,24.001 C16,0 40,0 40,0 " class="fourth"/>
<path d="M40,0 L72,0 L72,8 " class="fifth"/>
<path d="M40,16 L72,16 L72,8 " class="fifth"/>
</g>
</svg>
<div style="margin-top: 50px;">
<button id="restart"><svg height="16px" width="16px" aria-hidden="true" data-prefix="fas" data-icon="sync" class="svg-inline--fa fa-sync fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M440.935 12.574l3.966 82.766C399.416 41.904 331.674 8 256 8 134.813 8 33.933 94.924 12.296 209.824 10.908 217.193 16.604 224 24.103 224h49.084c5.57 0 10.377-3.842 11.676-9.259C103.407 137.408 172.931 80 256 80c60.893 0 114.512 30.856 146.104 77.801l-101.53-4.865c-6.845-.328-12.574 5.133-12.574 11.986v47.411c0 6.627 5.373 12 12 12h200.333c6.627 0 12-5.373 12-12V12c0-6.627-5.373-12-12-12h-47.411c-6.853 0-12.315 5.729-11.987 12.574zM256 432c-60.895 0-114.517-30.858-146.109-77.805l101.868 4.871c6.845.327 12.573-5.134 12.573-11.986v-47.412c0-6.627-5.373-12-12-12H12c-6.627 0-12 5.373-12 12V500c0 6.627 5.373 12 12 12h47.385c6.863 0 12.328-5.745 11.985-12.599l-4.129-82.575C112.725 470.166 180.405 504 256 504c121.187 0 222.067-86.924 243.704-201.824 1.388-7.369-4.308-14.176-11.807-14.176h-49.084c-5.57 0-10.377 3.842-11.676 9.259C408.593 374.592 339.069 432 256 432z"></path></svg></button>
<div>
body {
padding: 1rem;
background-color: black;
}
svg {
overflow: visible !important;
fill: none;
}
.letter path {
fill: none;
stroke: #FFF;
}
.circle rect {
stroke: #fff;
}
var speed = 1;
var path = anime.path('.path');
var restart = document.querySelector('#restart');
var timeline = anime.timeline({});
var pathTimeline = anime.timeline({});
pathTimeline
.add({
targets: '.circle rect',
strokeDashoffset: 49.94157791137695,
strokeDasharray: 24.97078895568848,
rotate: '0deg',
duration: 77 * speed,
easing: 'linear'
})
.add({
targets: '.circle',
translateX: path('x'),
translateY: path('y'),
rotate: path('angle'),
duration: 2000 * speed,
// loop: true,
easing: 'linear',
offset: 0
})
.add({
targets: '.circle rect',
rx: 0,
ry: 0,
strokeDashoffset: 56,
strokeDasharray: 32,
easing: 'linear',
duration: 50 * speed,
});
timeline
.add({
targets: '.letter .first',
strokeDashoffset: [anime.setDashoffset, 0],
easing: 'linear',
duration: 450 * speed,
delay: 77 * speed,
})
.add({
targets: '.letter .second',
strokeDashoffset: [anime.setDashoffset, 0],
easing: 'linear',
duration: 556 * speed,
offset: '-=0'
})
.add({
targets: '.letter .third',
strokeDashoffset: [anime.setDashoffset, 0],
easing: 'linear',
duration: 91 * speed,
offset: '-=0'
})
.add({
targets: '.letter .fourth',
strokeDashoffset: [anime.setDashoffset, 0],
easing: 'linear',
duration: 556 * speed,
offset: '-=0'
})
.add({
targets: '.letter .fifth',
strokeDashoffset: [anime.setDashoffset, 0],
easing: 'linear',
duration: 450 * speed,
offset: '-=0'
})
.add({
targets: '.stripe',
strokeWidth: function(el, i, l) {
var width = 80/6;
return (width * l) - (i * width);
},
delay: function(el, i, l) {
return 200 * i;
},
elasticity: 800
});
restart.addEventListener('click', function() {
timeline.restart();
pathTimeline.restart();
});
Also see: Tab Triggers