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 class="b c outer">
<noscript>
<div class="b c" style="color:red;font-size:24px">This clock needs JavaScript</div>
</noscript>
<div class="b c circle" id="off">
<div class="b n">
<span class="b ib tn">7</span>
<span class="b ib tn">1</span>
</div>
<div class="b n">
<span class="b ib tn">8</span>
<span class="b ib tn">2</span>
</div>
<div class="b n">
<span class="b ib tn">9</span>
<span class="b ib tn">3</span>
</div>
<div class="b n">
<span class="b ib tn">10</span>
<span class="b ib tn">4</span>
</div>
<div class="b n">
<span class="b ib tn">11</span>
<span class="b ib tn">5</span>
</div>
<div class="b n">
<span class="b ib tn">12</span>
<span class="b ib tn">6</span>
</div>
<div class="b c needle short" id="hour"></div>
<div class="b c needle medium" id="minute"></div>
<div class="b c needle long" id="second">
<div class="b c pivot"></div>
</div>
<div class="b c br">CLOCK</div>
</div>
<p class="b c dn" id="note"><small>Click clock to mute.</small></p>
</div>
/*static 300px x 300px of dimensions*/
body {
background: tan;
padding: 10px 0;
background-color: tan;
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cmFkaWFsR3JhZGllbnQgaWQ9Imc4MjciIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjeD0iNTAlIiBjeT0iMCUiIHI9Ijc1JSI+CjxzdG9wIHN0b3AtY29sb3I9IiNkMmQ0OGMiIG9mZnNldD0iMCIvPjxzdG9wIHN0b3AtY29sb3I9IiNkMmI0OGMiIG9mZnNldD0iMSIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8cmVjdCB4PSItNTAiIHk9Ii01MCIgd2lkdGg9IjEwMSIgaGVpZ2h0PSIxMDEiIGZpbGw9InVybCgjZzgyNykiIC8+Cjwvc3ZnPg==);
background-repeat: repeat-x;
background-position: top center;
height: 320px;
}
.b {
padding: 0;
margin: 0;
box-sizing: border-box;
font-size: 16px;
color: #000;
font-family: consolas, monaco, menlo, courier, monospace;
border: 0;
line-height: normal;
}
.c {
text-align: center;
margin: auto;
}
.ib {
display: inline-block;
}
.circle {
height: 300px;
width: 300px;
border: 10px solid #333;
background-color: #ddd;
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cmFkaWFsR3JhZGllbnQgaWQ9ImczNzMiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjeD0iNTAlIiBjeT0iNTAlIiByPSIyMDAlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIwIi8+PHN0b3Agc3RvcC1jb2xvcj0iIzg4OCIgb2Zmc2V0PSIxIi8+CjwvcmFkaWFsR3JhZGllbnQ+CjxyZWN0IHg9Ii01MCIgeT0iLTUwIiB3aWR0aD0iMTAxIiBoZWlnaHQ9IjEwMSIgZmlsbD0idXJsKCNnMzczKSIgLz4KPC9zdmc+);
background-position: center;
background-repeat: no-repeat;
border-radius: 20px;
overflow: hidden;
display: none;
transition: border-radius 0.25s;
}
.n {
position: absolute;
width: 280px;
height: 22px;
margin-top: 129px;
transform-origin: center center;
z-index: 2;
}
.br {
position: absolute;
margin-top: 80px;
margin-left: 85px;
font-size: 24px;
width: 100px;
color: #bbb;
text-shadow: 1px 1px 2px #fff;
}
.dn {
display: none;
margin-top: 10px;
}
.n:first-child {
transform: rotate(-60deg)
}
.n:first-child > .tn {
transform: rotate(60deg);
}
.n:nth-child(2) {
transform: rotate(-30deg)
}
.n:nth-child(2) > .tn {
transform: rotate(30deg);
}
.n:nth-child(3) {
transform: rotate(0)
}
.n:nth-child(3) > .tn {
transform: rotate(0deg);
}
.n:nth-child(4) {
transform: rotate(30deg)
}
.n:nth-child(4) > .tn {
transform: rotate(-30deg);
}
.n:nth-child(5) {
transform: rotate(60deg)
}
.n:nth-child(5) > .tn {
transform: rotate(-60deg);
}
.n:nth-child(6) {
transform: rotate(90deg)
}
.n:nth-child(6) > .tn {
transform: rotate(-90deg);
}
.tn {
float: right;
text-shadow: 1px 1px 2px #fff;
color: #888;
padding: 4px;
height: 22px;
width: 22px;
font-size: 12px;
border-radius: 50%;
transform-origin: center center;
}
.tn:first-of-type {
float: left;
}
.needle {
position: absolute;
height: 4px;
background: #333;
border-radius: 100% 5px 5px 100%;
width: 145px;
margin-top: 138px;
margin-left: 12px;
transform-origin: 128px 50%;
background: brown;
z-index: 5;
}
.medium {
height: 8px;
width: 120px;
margin-top: 136px;
margin-left: 37px;
background: rosybrown;
z-index: 4;
transform-origin: 102px 50%;
}
.short {
height: 10px;
width: 100px;
margin-top: 136px;
margin-left: 57px;
background: #333;
transform-origin: 83px 50%;
z-index: 3;
}
.pivot {
height: 16px;
width: 16px;
border-radius: 50%;
border: 4px solid brown;
background: #fff;
position: relative;
float: right;
right: 10px;
top: -6px;
box-shadow: 0 0 4px #000 inset;
}
.circle:hover {
cursor: pointer;
border-radius: 50%;
}
$(function () {
"use strict";
var $sec = $("#second");
var $min = $("#minute");
var $hour = $("#hour");
// This is the audio in base64 URI
// Tool for conversion: http://portraptor.johanpaul.net/2016/05/base64-audiovideo-converter.html
var uso = "data:audio/mp3;base64,SUQzAwAAAAAfdlBSSVYAAAAOAABQZWFrVmFsdWUA/n8AAFBSSVYAAA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G0oA+1rmNesuW9ztqj03ZiIzC+eRMoUBHBYTPAjTjAo6lr5NDNE49p1aswlT1JY1u3ur2NU9lQAQAiJqpcwyK8tj86RAVbrebCRgLDJ3B/cfm4n4nu2tRuMhcjScbrLSAmS7Vsz/n9+5mW+ZLzup6sNAH0BaZpprwXyYrLmMwqm3ef8///vlmKk//95jkQCAiRKRKUFh9OwkhHwdSqgIys6KVlR6Ps1t/L88/7ld7fIrfl0cPQ4CPDm0gtB1pWt0Elu40Xpegm629lUsL2L4j35WpARAhJCq6mK2EEVaQh3av/oQK+MkEeJJNTGLbLQVosnUpFfQI/QCW7MFEjO6OlZWFIBEx0EKwynXJ0HCiMNdavkff/+pNEchJvgAKxKVTx6zLaRiM6jzFmSQsE20nGNGthMwzpfJYhJFNiOGhwwoBCpJQZCbA0eyK+RqW60teKqgJGRptpt4JNgqSWDwSshJCdoEXbNUerOLstOrM0j0mtrANgXM9MrE9mnSY8YFDYUBpq9YTSdEQGnVBVy8Kiz26JVxIGNT/VmRFLcXwECm1VKAfbihWB9DifuGNH8c4CSBomrd6+s+nexYL3Va6smFQRM1GKqFlUUsqopWqzaEs+1pw2NXGVLImrzygRItNy7LCuKKwhsJ435QX///yf53Gkz7fwKaUaAJJKSRMYGfWcDoRoWSUkU4BmPMtqEtzl7Zi+uvHxxE8hZWRIc0qGWbjG49VCk1v955fLVkHQFPK+Isi3Cgdyvhzlixv///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////qTRMOQjIAC1CZLYe9KWkSkCU0x6UgAAAEuAAAAIAAAJcAAAAT///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/6k0R6YfqAC5AAS4AAAAgAAAlwAAABAAABLgAAACAAACXAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABUQUcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgDA==";
var audio;
var ct = -1;
function run(e) {
// This one is the clock value from your computer's time n date
function getTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
return [h, m, s];
}
function needleAnimation() {
// Init the clock display
if ($("#off").css("display") === "none") {
$("#off").fadeIn(300, function () {
if (!e && $("#note").css("display") === "none") {
$("#note").fadeIn(300);
}
});
}
var time = getTime();
if (!e) { // Run with audio
ct += 1; // ct is the index of created "Audio" object
if (ct > 4) {
ct = 0;
}
audio[ct].play();
}
var s_value = time[2] * 6 + 90;
var m_value = time[1] * 6 + 90;
var h_value = (time[0] % 12) * 30 + 90 + (time[1] / 60) * 30;
var secS = ((Math.cos(s_value / 180 * Math.PI)) * 3) + "px " + ((Math.sin(s_value / 180 * Math.PI)) * 3) + "px 3px rgba(0, 0, 0, 0.25)";
var minS = ((Math.cos(m_value / 180 * Math.PI)) * 2) + "px " + ((Math.sin(m_value / 180 * Math.PI)) * 2) + "px 2px rgba(0, 0, 0, 0.8)";
// This is for the needles rotation
$sec.css({transform: "rotate(" + s_value + "deg)", "box-shadow": secS});
$min.css({transform: "rotate(" + m_value + "deg)", "box-shadow": minS});
$hour.css({transform: "rotate(" + h_value + "deg)"});
}
// 1000 ms = 1 s interval period
setInterval(needleAnimation, 1000);
}
// For mute and changing the color
function clickOff() {
function turnOn(v) {
v.volume = 0.2;
}
function turnOff(v) {
v.volume = 0;
}
if (audio[0].volume === 0) {
audio.forEach(turnOn);
$("#off").css({
"background-image": "url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cmFkaWFsR3JhZGllbnQgaWQ9ImczNzMiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjeD0iNTAlIiBjeT0iNTAlIiByPSIyMDAlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIwIi8+PHN0b3Agc3RvcC1jb2xvcj0iIzg4OCIgb2Zmc2V0PSIxIi8+CjwvcmFkaWFsR3JhZGllbnQ+CjxyZWN0IHg9Ii01MCIgeT0iLTUwIiB3aWR0aD0iMTAxIiBoZWlnaHQ9IjEwMSIgZmlsbD0idXJsKCNnMzczKSIgLz4KPC9zdmc+)",
"background-color": "#ddd"
});
$("#note").html("<small>Click clock to mute.</small>");
$(".tn").css("color", "#888");
} else {
audio.forEach(turnOff);
$("#off").css({
"background-image": "url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cmFkaWFsR3JhZGllbnQgaWQ9Imc1MTUiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjeD0iNTAlIiBjeT0iNTAlIiByPSI1MCUiPgo8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAiLz48c3RvcCBzdG9wLWNvbG9yPSIjODdjZWZhIiBvZmZzZXQ9IjEiLz4KPC9yYWRpYWxHcmFkaWVudD4KPHJlY3QgeD0iLTUwIiB5PSItNTAiIHdpZHRoPSIxMDEiIGhlaWdodD0iMTAxIiBmaWxsPSJ1cmwoI2c1MTUpIiAvPgo8L3N2Zz4=)",
"background-color": "lightskyblue"
});
$("#note").html("<small style='color:brown;letter-spacing:1px;font-weight:bold;'>MUTED</small>");
$(".tn").css("color", "#555");
}
}
/*
ABOUT REPEATEDLY PLAYING AUDIO
---------------------------
A. Using audio file:
---------------------
1. The trick to play over and over the same (short) audio is to create more than 1 "Audio" object. Then repeat the play() invocation for each different object.
2. Or use 1 object, attach a listener (ended event), then chain that to your other trigger if the app something stuff nanana. This one is less efficient. You'll have no "buffer".
---------------------
B. Using web audio API:
---------------------
Synthesize it using web audio API. That takes superposition of multifrequency, phase and oscillation types and maybe filter(s) to mimic the ticking sound. Boy that's something.
*/
(function () {
var i = 0;
if (Audio !== undefined) {
audio = new Audio(uso);
if (audio.canPlayType("audio/mp3") !== "") {
$("#off").click(clickOff); // Muting trigger
audio = [];
// Here, I create 5 "Audio" objects
while (i < 5) {
audio.push(new Audio(uso));
audio[i].volume = 0.2;
i += 1;
}
run(0); // Run with audio
} else {
run(1); // Run without audio
}
} else {
run(1); // Run without audio
}
}());
});
Also see: Tab Triggers