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 id="clock"></div>
<svg>
<font id="Ubuntu-Light" horiz-adv-x="376">
<glyph glyph-name="space" unicode=" " horiz-adv-x="228" />
<glyph glyph-name="zero" unicode="0" horiz-adv-x="564" d="M59 346q0 176 58 269t165 93q106 0 164.5 -93t58.5 -269q0 -175 -58.5 -268t-164.5 -93t-164.5 93t-58.5 268zM434 346q0 60 -7.5 114.5t-25.5 96.5t-47 67t-72 25q-44 0 -73 -25t-46.5 -67t-25 -96.5t-7.5 -114.5t7.5 -114.5t25 -96t46.5 -66.5t73 -25q43 0 72 25
t47 66.5t25.5 96t7.5 114.5z" />
<glyph glyph-name="one" unicode="1" horiz-adv-x="564" d="M107 551q60 21 107 53.5t93 88.5h46v-693h-65v594q-11 -12 -28.5 -25t-39.5 -25.5t-46 -24t-48 -18.5z" />
<glyph glyph-name="two" unicode="2" horiz-adv-x="564" d="M456 521q0 -39 -14 -73.5t-37.5 -66.5t-53.5 -62t-61 -60q-26 -25 -50.5 -50.5t-44 -51t-31 -50t-11.5 -48.5v-2h327v-57h-399q0 2 -0.5 7.5t-0.5 16.5q0 47 17 87.5t43.5 76.5t59 67t62.5 60q25 24 47.5 46.5t39.5 46.5t27 51t10 59q0 70 -37.5 100.5t-94.5 30.5
q-32 0 -57 -8t-43.5 -18.5t-31.5 -21.5t-19 -17l-34 45q6 7 21.5 20.5t39 26.5t54.5 22.5t69 9.5q101 0 152 -49.5t51 -137.5z" />
<glyph glyph-name="three" unicode="3" horiz-adv-x="564" d="M235 45q95 0 136 39.5t41 106.5q0 44 -16.5 73t-45 46.5t-66 25t-79.5 7.5h-10v54h23q27 0 55.5 5.5t52 20.5t39 40t15.5 64q0 33 -11 56.5t-29.5 37.5t-43 20.5t-51.5 6.5q-54 0 -84 -15t-49 -28l-28 51q10 7 25.5 16t36.5 17t46.5 13.5t55.5 5.5q52 0 89.5 -13
t62.5 -36.5t37 -56t12 -70.5q0 -61 -32.5 -99.5t-83.5 -55.5q28 -7 54.5 -21.5t47.5 -37t34 -54.5t13 -75q0 -44 -15.5 -81t-46 -64.5t-77.5 -43t-110 -15.5q-33 0 -60.5 4.5t-48.5 10.5t-35.5 12t-21.5 10l17 58q6 -4 20 -10t33.5 -11.5t44 -9.5t53.5 -4z" />
<glyph glyph-name="four" unicode="4" horiz-adv-x="564" d="M50 228q18 48 50.5 108t73.5 123t89 123.5t97 110.5h68v-452h86v-53h-86v-188h-64v188h-314v40zM364 241v379q-35 -36 -71 -83t-68.5 -97.5t-60.5 -101.5t-47 -97h247z" />
<glyph glyph-name="five" unicode="5" horiz-adv-x="564" d="M239 45q50 0 83.5 11.5t53.5 31.5t28.5 46.5t8.5 57.5q0 40 -13 72t-46 54t-89 33.5t-142 11.5q6 51 10 93.5t7 82t4.5 77t2.5 77.5h312v-57h-255q-1 -19 -3 -49t-4 -61.5t-5 -60.5t-5 -46q77 -2 133 -19t92 -46t53.5 -70t17.5 -91q0 -44 -14.5 -82t-44.5 -66t-76 -44
t-109 -16q-32 0 -59.5 4.5t-49 10.5t-36.5 12t-22 10l17 58q6 -4 20.5 -10t34 -11.5t44 -9.5t51.5 -4z" />
<glyph glyph-name="six" unicode="6" horiz-adv-x="564" d="M77 275q0 203 97.5 308t283.5 113l4 -55q-61 -4 -112.5 -18.5t-91.5 -45t-67 -78.5t-37 -118q27 14 65 24.5t81 10.5q56 0 95 -17.5t63 -46.5t35 -67t11 -80q0 -39 -12 -78t-37.5 -70.5t-64 -51.5t-91.5 -20q-109 0 -165.5 76.5t-56.5 213.5zM294 359q-46 0 -80.5 -10.5
t-64.5 -24.5q-2 -17 -2 -26.5v-23.5q0 -47 6.5 -89t24 -74t46.5 -50.5t74 -18.5q37 0 63 13.5t42 35.5t23.5 51t7.5 61q0 80 -35.5 118t-104.5 38z" />
<glyph glyph-name="seven" unicode="7" horiz-adv-x="564" d="M175 0q6 83 30.5 176t60 180t77 160t80.5 117h-354v60h421v-58q-34 -41 -74.5 -109.5t-76.5 -154t-62.5 -181.5t-32.5 -190h-69z" />
<glyph glyph-name="eight" unicode="8" horiz-adv-x="564" d="M282 -15q-49 0 -88.5 14t-68 39.5t-44 60t-15.5 75.5q0 35 10 63.5t26.5 51t38 40t45.5 30.5q-61 30 -83 71t-22 89q0 43 15 78t41.5 59.5t63.5 38t81 13.5q52 0 90 -15.5t62.5 -40.5t36 -57t11.5 -66q0 -33 -10 -60.5t-26 -50t-36 -39.5t-39 -29q70 -30 98.5 -75
t28.5 -95q0 -43 -15.5 -79t-43.5 -61.5t-68 -40t-89 -14.5zM429 174q0 43 -16.5 70t-43 44t-60 27t-67.5 21q-51 -24 -79 -64.5t-28 -97.5q0 -28 9 -52t27.5 -42t46 -28.5t64.5 -10.5t64.5 10.5t46 28.5t27.5 42t9 52zM149 526q0 -28 6.5 -51t24.5 -41.5t50 -34t84 -29.5
q46 26 73 64t27 95q0 23 -7.5 45t-23 39.5t-40.5 28t-61 10.5q-33 0 -58 -10t-41.5 -27.5t-25 -40.5t-8.5 -48z" />
<glyph glyph-name="nine" unicode="9" horiz-adv-x="564" d="M490 418q0 -209 -100 -314.5t-292 -105.5l-2 54q66 0 121 15t95.5 46.5t66 81t34.5 119.5q-27 -14 -65 -24.5t-81 -10.5q-56 0 -95 17.5t-63 46.5t-35 67t-11 79q0 38 12 77t37.5 70.5t64 51.5t91.5 20q109 0 165.5 -76.5t56.5 -213.5zM273 336q46 0 80.5 10.5t64.5 24.5
q1 12 1.5 23t0.5 25q0 47 -6.5 89t-24 74t-46.5 50.5t-74 18.5q-37 0 -63 -13.5t-42 -35.5t-23.5 -51t-7.5 -60q0 -79 35.5 -117t104.5 -38z" />
<glyph glyph-name="colon" unicode=":" horiz-adv-x="246" d="M178 43q0 -23 -14.5 -39t-40.5 -16t-40.5 16t-14.5 39t14.5 39t40.5 16t40.5 -16t14.5 -39zM178 462q0 -23 -14.5 -39t-40.5 -16t-40.5 16t-14.5 39t14.5 39t40.5 16t40.5 -16t14.5 -39z" />
</font>
</svg>
body{ background-color: #000; }
svg{ display: none; }
#clock{
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: scale(1,-1) translate(-50%, 50%);
-moz-transform: scale(1,-1) translate(-50%, 50%);
-ms-transform: scale(1,-1) translate(-50%, 50%);
-o-transform: scale(1,-1) translate(-50%, 50%);
transform: scale(1,-1) translate(-50%, 50%);
}
.section{
position: relative;
float: left;
width: 110px;
height: 150px;
}
.section:nth-child(3),
.section:nth-child(6){
width: 40px;
}
.particle{
position: absolute;
border-radius: 100%;
background-color: #FFF;
box-shadow: 0px 0px 3px #FFF;
-webkit-transition: all .5s ease-in-out ;
-moz-transition: all .5s ease-in-out ;
-ms-transition: all .5s ease-in-out ;
-o-transition: all .5s ease-in-out ;
transition: all .5s ease-in-out ;
}
// Init path object
var p = document.createElementNS('http://www.w3.org/2000/svg','path');
var fragment = document.createDocumentFragment();
// particles variables
var particleMinRadius = 2,
particleMaxRadius = 4,
fontRatio = 200,
numParticles = 60,
particles = new Array(),
letters,
path,
section,
currentdate;
function timeUpdate(){
currentdate = new Date();
var text = ("0" + currentdate.getHours()).slice(-2) + ':' + ("0" + currentdate.getMinutes()).slice(-2) + ':' + ("0" + currentdate.getSeconds()).slice(-2);
var textArray = text.split('');
// Parse each letter of the text to get its path
for(var c = 0, l = textArray.length; c < l; c++){
// skip if it's the same letter
if(letters && letters[c] && letters[c] == textArray[c]) continue;
letter = textArray[c];
// create the initial path
path = document.querySelector("glyph[unicode='"+textArray[c]+"']").getAttribute("d");
p.setAttribute('d', path);
if(!particles[c]){
particles[c] = new Array();
section = document.createElement('div');
section.className = 'section';
fragment.appendChild( section );
}
var len = p.getTotalLength();
for (var i = 0; i <= numParticles; ++i){
var pct = i/numParticles + Math.random()/100,
pt = p.getPointAtLength(pct*len),
particle;
if(particles[c][i]){
particle = particles[c][i];
}else{
particle = document.createElement('div');
particle.className = 'particle';
particles[c][i] = particle;
section.appendChild( particle );
}
var posX = Math.round((pt.x / 1000) * fontRatio);
var posY = Math.round((pt.y / 1000) * fontRatio);
// particle.style.left = posX + 'px';
// particle.style.top = posY + 'px';
var prop = "translate("+posX+"px, "+posY+"px)";
particle.style.webkitTransform = prop;
particle.style.MozTransform = prop;
particle.style.msTransform = prop;
particle.style.OTransform = prop;
particle.style.transform = prop;
var particleRadius = particleMinRadius + ( Math.random() * (particleMaxRadius - particleMinRadius));
particle.style.width = particle.style.height = particleRadius + 'px';
}
}
letters = textArray;
}
var clock = document.getElementById('clock');
timeUpdate();
clock.appendChild( fragment );
setInterval(timeUpdate, 1000);
Also see: Tab Triggers