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.
<audio class="customPlayer" src="http://audio.eatenbymonsters.com/reviews/daughter/human.mp3" title="Human" data-artist="Daughter" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<p style="font-family:sans-serif;">Built using <a href="http://audio.tomhazledine.com/">Picobel.js</a></p>
@charset "UTF-8";.pitchfork.customAudioPlayer{margin:2em 0;padding:1em 1em 1em 4em;position:relative;border:2px solid #a2a2a2;overflow:hidden;box-sizing:border-box;background:#fff;font-family:Arial,sans-serif;color:#969696}.pitchfork.customAudioPlayer *,.pitchfork.customAudioPlayer :after,.pitchfork.customAudioPlayer :before{box-sizing:inherit}.pitchfork.customAudioPlayer .loader{position:absolute;top:3.1em;left:7.2em;right:4.2em;height:.4em;z-index:2;pointer-events:none;opacity:0;transition:opacity .2s;text-align:center;line-height:1;overflow:hidden;border-radius:.2em}.pitchfork.customAudioPlayer .loader:before{display:block;content:'';width:130%;height:600%;position:absolute;z-index:1;top:-200%;left:0;box-shadow:inset #eee 0 0 0 0,inset #dad8d2 .5em 0 0 0,inset #eee 1em 0 0 0,inset #dad8d2 1.5em 0 0 0,inset #eee 2em 0 0 0,inset #dad8d2 2.5em 0 0 0,inset #eee 3em 0 0 0,inset #dad8d2 3.5em 0 0 0,inset #eee 4em 0 0 0,inset #dad8d2 4.5em 0 0 0,inset #eee 5em 0 0 0,inset #dad8d2 5.5em 0 0 0,inset #eee 6em 0 0 0,inset #dad8d2 6.5em 0 0 0,inset #eee 7em 0 0 0,inset #dad8d2 7.5em 0 0 0,inset #eee 8em 0 0 0,inset #dad8d2 8.5em 0 0 0,inset #eee 9em 0 0 0,inset #dad8d2 9.5em 0 0 0,inset #eee 10em 0 0 0,inset #dad8d2 10.5em 0 0 0,inset #eee 11em 0 0 0,inset #dad8d2 11.5em 0 0 0,inset #eee 12em 0 0 0,inset #dad8d2 12.5em 0 0 0,inset #eee 13em 0 0 0,inset #dad8d2 13.5em 0 0 0,inset #eee 14em 0 0 0,inset #dad8d2 14.5em 0 0 0,inset #eee 15em 0 0 0,inset #dad8d2 15.5em 0 0 0,inset #eee 16em 0 0 0,inset #dad8d2 16.5em 0 0 0,inset #eee 17em 0 0 0,inset #dad8d2 17.5em 0 0 0,inset #eee 18em 0 0 0,inset #dad8d2 18.5em 0 0 0,inset #eee 19em 0 0 0,inset #dad8d2 19.5em 0 0 0,inset #eee 20em 0 0 0,inset #dad8d2 20.5em 0 0 0,inset #eee 21em 0 0 0,inset #dad8d2 21.5em 0 0 0,inset #eee 22em 0 0 0,inset #dad8d2 22.5em 0 0 0,inset #eee 23em 0 0 0,inset #dad8d2 23.5em 0 0 0,inset #eee 24em 0 0 0,inset #dad8d2 24.5em 0 0 0,inset #eee 25em 0 0 0,inset #dad8d2 25.5em 0 0 0,inset #eee 26em 0 0 0,inset #dad8d2 26.5em 0 0 0,inset #eee 27em 0 0 0,inset #dad8d2 27.5em 0 0 0,inset #eee 28em 0 0 0,inset #dad8d2 28.5em 0 0 0,inset #eee 29em 0 0 0,inset #dad8d2 29.5em 0 0 0,inset #eee 30em 0 0 0,inset #dad8d2 30.5em 0 0 0,inset #eee 31em 0 0 0,inset #dad8d2 31.5em 0 0 0,inset #eee 32em 0 0 0,inset #dad8d2 32.5em 0 0 0,inset #eee 33em 0 0 0,inset #dad8d2 33.5em 0 0 0,inset #eee 34em 0 0 0,inset #dad8d2 34.5em 0 0 0,inset #eee 35em 0 0 0,inset #dad8d2 35.5em 0 0 0,inset #eee 36em 0 0 0,inset #dad8d2 36.5em 0 0 0,inset #eee 37em 0 0 0,inset #dad8d2 37.5em 0 0 0,inset #eee 38em 0 0 0,inset #dad8d2 38.5em 0 0 0,inset #eee 39em 0 0 0,inset #dad8d2 39.5em 0 0 0,inset #eee 40em 0 0 0,inset #dad8d2 40.5em 0 0 0,inset #eee 41em 0 0 0,inset #dad8d2 41.5em 0 0 0,inset #eee 42em 0 0 0,inset #dad8d2 42.5em 0 0 0,inset #eee 43em 0 0 0,inset #dad8d2 43.5em 0 0 0,inset #eee 44em 0 0 0,inset #dad8d2 44.5em 0 0 0,inset #eee 45em 0 0 0,inset #dad8d2 45.5em 0 0 0,inset #eee 46em 0 0 0,inset #dad8d2 46.5em 0 0 0,inset #eee 47em 0 0 0,inset #dad8d2 47.5em 0 0 0,inset #eee 48em 0 0 0,inset #dad8d2 48.5em 0 0 0,inset #eee 49em 0 0 0,inset #dad8d2 49.5em 0 0 0,inset #eee 50em 0 0 0;animation:pitchfork_slide linear infinite .3s;transform-origin:center}.pitchfork.customAudioPlayer.loading .loader{opacity:1}.pitchfork.customAudioPlayer .playerTrigger{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:2.6em;height:2.6em;font-size:1em;color:#7f7f7f;background:#fff;position:absolute;top:50%;margin-top:-1.3em;left:1em;border:2px solid #000;border-radius:50%;cursor:pointer}.pitchfork.customAudioPlayer .playerTrigger .buttonText{display:none}.pitchfork.customAudioPlayer .playerTrigger:focus{outline:0}.pitchfork.customAudioPlayer .playerTrigger:before{content:'';display:block;position:absolute;top:50%;left:50%;margin-top:-.6em;margin-left:-.25em;border-top:.6em solid transparent;border-left:.8em solid #000;border-bottom:.6em solid transparent}.pitchfork.customAudioPlayer .playerTrigger:after{content:'';display:block;position:absolute;top:50%;right:50%;height:1em;margin-top:-.5em;margin-right:-.5em;border-top:0;border-left:.4em solid #000;border-bottom:0;opacity:0}.pitchfork.customAudioPlayer .songProgressSliderWrapper .pseudoProgressPlayhead,.pitchfork.customAudioPlayer .songVolume{display:none}.pitchfork.customAudioPlayer .playerTrigger.songPlaying:before{height:1em;margin-top:-.5em;margin-left:-.5em;border-top:0;border-left:.4em solid #000;border-bottom:0}.pitchfork.customAudioPlayer .playerTrigger.songPlaying:after{opacity:1}.pitchfork.customAudioPlayer .metaWrapper{color:#000;padding:0 1em;margin-bottom:1em}.pitchfork.customAudioPlayer .titleDisplay{font-weight:700}.pitchfork.customAudioPlayer .titleDisplay:before{content:'“'}.pitchfork.customAudioPlayer .titleDisplay:after{content:'”'}.pitchfork.customAudioPlayer .artistDisplay:before{content:' – '}.pitchfork.customAudioPlayer .songPlayTimer{position:absolute;bottom:1em;left:5em}.pitchfork.customAudioPlayer .songDuration{position:absolute;bottom:1em;right:1em}.pitchfork.customAudioPlayer .timingsWrapper{padding:0 4em;position:relative;font-size:.8em;width:100%;float:left}.pitchfork.customAudioPlayer .timingsWrapper .songDuration,.pitchfork.customAudioPlayer .timingsWrapper .songPlayTimer{position:absolute;top:-.2em;width:4em;text-align:center;line-height:1}.pitchfork.customAudioPlayer .timingsWrapper .songPlayTimer{left:0;border-radius:.5em 0 0 .5em}.pitchfork.customAudioPlayer .timingsWrapper .songDuration{right:0;border-radius:0 .5em .5em 0}.pitchfork.customAudioPlayer .songProgressSliderWrapper{height:.4rem;line-height:1;position:relative;border-radius:.2rem;overflow:hidden}.pitchfork.customAudioPlayer .songProgressSliderWrapper .songProgressSlider{width:100%;padding:0;margin:0;position:absolute;top:0;left:0;opacity:0}.pitchfork.customAudioPlayer .songProgressSliderWrapper .pseudoProgressBackground{height:.4rem;position:absolute;bottom:0;left:0;background:#eee;width:100%}.pitchfork.customAudioPlayer .songProgressSliderWrapper .pseudoProgressIndicator{height:.4rem;position:absolute;bottom:0;left:0;background:#ff3530;width:0}.pitchfork.customAudioPlayer input[type=range].songProgressSlider::-webkit-slider-runnable-track{width:100%;font-size:.4rem;height:2.2em;cursor:pointer}.pitchfork.customAudioPlayer input[type=range].songProgressSlider::-moz-range-track{width:100%;height:.4rem;cursor:pointer}.pitchfork.customAudioPlayer input[type=range].songProgressSlider::-ms-track{width:100%;height:.4rem;cursor:pointer}@keyframes pitchfork_slide{0%{transform:translateX(-2em)}100%{transform:translateX(0)}}
// Picobel.js
function Picobel(e){function t(){var e=document.getElementsByTagName("audio"),t=[].slice.call(e);return t}function n(e){output=[];for(var t=0;t<e.length;t++)item={},item.url=e[t].src,output.push(item);return output}function a(t){for(var n=0;n<t.length;n++){var a=document.createElement("div");a.className="customAudioPlayer loading player_"+n;var s=H[n].className;""!==s&&M(a,s),M(a,e.theme),a.setAttribute("data-song-index",n);var r=document.createElement("div");r.className="loader",a.appendChild(r);var i=document.createElement("button");i.className="playerTrigger";var d=document.createElement("span");d.className="buttonText",d.innerHTML="play",i.appendChild(d);var l=document.createElement("div");l.className="metaWrapper";var o=document.createElement("span");o.className="titleDisplay",o.innerHTML="File "+(n+1),l.appendChild(o);var u=document.createElement("span");u.className="artistDisplay",l.appendChild(u);var m=document.createElement("div");m.className="timingsWrapper";var c=document.createElement("span");c.className="songPlayTimer",c.innerHTML="0:00",m.appendChild(c);var p=document.createElement("div");p.className="songProgressSliderWrapper";var g=document.createElement("div");g.className="pseudoProgressBackground",p.appendChild(g);var v=document.createElement("div");v.className="pseudoProgressIndicator",p.appendChild(v);var h=document.createElement("div");h.className="pseudoProgressPlayhead",p.appendChild(h);var N=document.createElement("input");N.type="range",N.min=0,N.max=100,N.value=0,N.className="songProgressSlider",p.appendChild(N),m.appendChild(p);var y=document.createElement("span");y.className="songDuration",y.innerHTML="-:--",m.appendChild(y);var E=document.createElement("div");E.className="songVolume";var f=document.createElement("button");f.className="songMuteButton",f.innerHTML="Mute",E.appendChild(f);var C=document.createElement("div");C.className="songVolumeLabelWrapper";var L=document.createElement("span");L.className="songVolumeLabel",L.innerHTML="Volume",C.appendChild(L);var P=document.createElement("span");P.className="songVolumeValue",P.innerHTML="10",C.appendChild(P),E.appendChild(C);var T=document.createElement("div");T.className="songVolumeSliderWrapper";var b=document.createElement("div");b.className="pseudoVolumeBackground",T.appendChild(b);var x=document.createElement("div");x.className="pseudoVolumeIndicator",T.appendChild(x);var B=document.createElement("div");B.className="pseudoVolumePlayhead",T.appendChild(B);var A=document.createElement("input");A.type="range",A.min=0,A.max=1,A.value=1,A.step=.1,A.className="songVolumeSlider",T.appendChild(A),E.appendChild(T),a.appendChild(i),a.appendChild(l),a.appendChild(m),a.appendChild(E),t[n].parentNode.replaceChild(a,t[n])}}function s(e){for(var t=[],n=0;n<e.length;n++)t[n]=new Audio(e[n].url),t[n].currentTime=0,w[n].addEventListener("click",h,!1),U[n].addEventListener("input",m,!1),O[n].addEventListener("input",c,!1),t[n].addEventListener("timeupdate",y,!1),t[n].addEventListener("loadstart",r,!1),t[n].addEventListener("canplaythrough",d,!1),D[n].addEventListener("click",N,!1),t[n].addEventListener("error",C,!1),t[n].addEventListener("stalled",L,!1),t[n].addEventListener("waiting",C,!1),t[n].addEventListener("progress",P,!1),t[n].setAttribute("data-song-index",n);return t}function r(){}function d(){var e=this.getAttribute("data-song-index");f(e),x(S[e],"loading"),l(e)}function l(e){var t=G[e].src,n=B(t),a=A(t),s=H[e].title;""!==s?k[e].innerHTML=s:k[e].innerHTML=a+"."+n;var r=H[e].getAttribute("data-artist");""!==r&&(R[e].innerHTML=r)}function o(){for(var e=0;e<V.length;e++)G[e].pause()}function u(e){J=e;for(var t=0;t<V.length;t++)t!=e&&G[t].pause();G[e].play()}function m(){var e=this.value,t=this.parentNode.parentNode.parentNode.getAttribute("data-song-index"),n=G[t].duration,a=n*(e/100);a=a.toFixed(2),G[t].currentTime=a,E(t)}function c(){var e=this.value,t=this.parentNode.parentNode.parentNode.getAttribute("data-song-index");g(t,!1),p(t,e)}function p(e,t){var n=10*t,a=100*t;G[e].volume=t,_[e].innerHTML=n,O[e].value=t,q[e].style.width=a+"%",z[e].style.left=a+"%"}function g(e,t){var n;t?(n=G[e].volume,D[e].setAttribute("data-saved-volume",n),p(e,0),M(D[e],"songMuted"),x(D[e],"songUnmuted"),D[e].innerHTML="unmute"):(n=D[e].getAttribute("data-saved-volume"),"undefined"!=typeof n&&n>0?p(e,n):p(e,1),x(D[e],"songMuted"),M(D[e],"songUnmuted"),D[e].innerHTML="mute")}function v(e,t){var n=F[e],a=w[e];if(t){for(i=0;i<w.length;i++)x(w[i],"songPlaying"),M(w[i],"songPaused"),F[i].innerHTML="play";u(e),M(a,"songPlaying"),x(a,"songPaused"),n.innerHTML="pause"}else o(),x(a,"songPlaying"),M(a,"songPaused"),n.innerHTML="play"}function h(){var e=this.parentNode.getAttribute("data-song-index");if("undefined"!=typeof e){var t=!b(this,"songPlaying");v(e,t)}else console.log("too soon to play!")}function N(){var e=this.parentNode.parentNode.getAttribute("data-song-index");F[e];b(this,"songMuted")?g(e,!1):g(e,!0)}function y(){var e=this.getAttribute("data-song-index");E(e)}function E(e){var t=G[e].currentTime,n=G[e].duration;progressParsed=T(t),I[e].innerHTML=progressParsed,t>=n&&x(w[e],"songPlaying");var a=(t/n*100).toFixed(2);U[e].value=a,j[e].style.width=a+"%",$[e].style.left=a+"%"}function f(e){var t=G[e].duration,n=T(t);W[e].innerHTML=n}function C(e){this.getAttribute("data-song-index")}function L(e){var t=this.getAttribute("data-song-index");v(t,!1)}function P(e){var t=this.getAttribute("data-song-index");G[t].readyState}function T(e){var t=Math.floor(e%3600/60);t=t.toFixed(0),t=t.toString();var n=Math.floor(e%3600%60);n=n.toFixed(0),n=n.toString(),n<10&&(n="0"+n);var a=t+":"+n;return a}function b(e,t){var n;return n=e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}function M(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function x(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")}function B(e){return e.substr((~-e.lastIndexOf(".")>>>0)+2)}function A(e){var t=e.replace(/^.*[\\\/]/,""),n=t.split(".")[0];return n}e="undefined"!=typeof e?e:{},e.theme=e.theme||"basicPlayer";var H=t(),V=n(H);a(H);var S=document.getElementsByClassName("customAudioPlayer"),w=document.getElementsByClassName("playerTrigger"),D=document.getElementsByClassName("songMuteButton"),F=document.getElementsByClassName("buttonText"),I=document.getElementsByClassName("songPlayTimer"),W=document.getElementsByClassName("songDuration"),k=document.getElementsByClassName("titleDisplay"),R=document.getElementsByClassName("artistDisplay"),U=document.getElementsByClassName("songProgressSlider"),$=document.getElementsByClassName("pseudoProgressPlayhead"),j=document.getElementsByClassName("pseudoProgressIndicator"),O=document.getElementsByClassName("songVolumeSlider"),_=document.getElementsByClassName("songVolumeValue"),q=document.getElementsByClassName("pseudoVolumeIndicator"),z=document.getElementsByClassName("pseudoVolumePlayhead"),G=s(V),J=0;return{sliderScrub:m,playSong:u,pauseAll:o}}
Picobel({theme:'pitchfork'});
Also see: Tab Triggers