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.
%main.pre-enter{:ontouchstart => true}
.background
%div
.container
.player
.back
%header
%h1
%a ‹
%h1 Up Next
%ol
%li
%a
%img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/obedear.jpg"}
%div
%h3 Obedear
%h4 Purity Ring
%hr
%li
%a
%img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/heartsigh.jpg"}
%div
%h3 Heartsigh
%h4 Purity Ring
%hr
%li
%a
%img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/empathy.jpg"}
%div
%h3 Empathy
%h4 Crystal Castles
%hr
%li
%a
%img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/adventure.jpg"}
%div
%h3 Adventure
%h4 Disasterpeace
%hr
%li
%a
%img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/points.jpg"}
%div
%h3 Between Two Points
%h4 The Glitch Mob
%hr
%li
%a
%img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/grotto.jpg"}
%div
%h3 Secret Grotto
%h4 Lifeformed
%hr
%li
%a
%img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/ida.jpg"}
%div
%h3 Ida's Theme
%h4 Grigori
.front
%img.art{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/thousand-thursday%402x.jpg"}
.bar
%hr
.meta
%time
%span 1:29
%span 2:58
.controls.top
%a.rewind.skip
%svg{:viewBox => "0 0 36 20"}
%path{:d => "M1.69813738,11.0254725 C0.75331072,10.4595484 0.761328762,9.53720142 1.69813738,8.97607983 L16.2885768,0.236823587 C17.2334034,-0.329100579 17.9993368,0.11180583 17.9993368,1.20339155 L17.9993368,18.7981608 C17.9993368,19.8979057 17.2253854,20.3258504 16.2885768,19.7647288 L1.69813738,11.0254725 Z"}
%path{:d => "M19.6988006,8.97607983 C18.7539739,9.542004 18.761992,10.4643509 19.6988006,11.0254725 L34.28924,19.7647288 C35.2340667,20.3306529 36,19.8897465 36,18.7981608 L36,1.20339155 C36,0.103646637 35.2260486,-0.324298001 34.28924,0.236823587 L19.6988006,8.97607983 Z"}
%a.play
%svg{:viewBox => "0 0 36 42"}
%path{:d => "M35.26504,19.9918476 C36.223232,20.5486348 36.2272024,21.4490581 35.26504,22.0081524 L1.73495997,41.4918476 C0.776768039,42.0486348 0,41.6018839 0,40.4980004 L0,1.50199958 C0,0.396325744 0.772797585,-0.0509419441 1.73495997,0.508152418 L35.26504,19.9918476 Z"}
%a.forward.skip
%svg{:viewBox => "0 0 36 20"}
%path{:d => "M34.3018626,8.97607983 C35.2466893,9.542004 35.2386712,10.4643509 34.3018626,11.0254725 L19.7114232,19.7647288 C18.7665966,20.3306529 18.0006632,19.8897465 18.0006632,18.7981608 L18.0006632,1.20339155 C18.0006632,0.103646637 18.7746146,-0.324298001 19.7114232,0.236823587 L34.3018626,8.97607983 Z"}
%path{:d => "M16.3011994,8.97607983 C17.2460261,9.542004 17.238008,10.4643509 16.3011994,11.0254725 L1.71075999,19.7647288 C0.765933339,20.3306529 0,19.8897465 0,18.7981608 L0,1.20339155 C0,0.103646637 0.773951381,-0.324298001 1.71075999,0.236823587 L16.3011994,8.97607983 Z"}
.info
%h1 Solid Gold (ft. MNDR)
%h2 Michna - Thousand Thursday
.controls.bottom
%a
%svg{:viewBox => "0 0 24 20"}
%path{:d => "M13.2373287,1.79729532 C15.7059873,-0.59131555 19.6719532,-0.59131555 22.1445244,1.80184551 C24.6188818,4.21700618 24.6188818,8.1293472 22.1428711,10.5355725 L12.713653,19.7107814 C12.3197664,20.0940573 11.6860418,20.0986738 11.2878246,19.7110025 L1.8660259,10.5387159 C-0.621617914,8.13135849 -0.621617914,4.21556839 1.86368241,1.79993513 C3.07278074,0.634789609 4.67258351,0 6.32148154,0 C7.96903306,0 9.56085834,0.633814887 10.7729901,1.80153767 L12.0029801,3.00139253 L13.2373287,1.79729532 Z M20.041022,8.41556527 C21.3200493,7.17258662 21.3200493,5.16867425 20.0431981,3.922352 C18.7408346,2.66182552 16.6367424,2.66182552 15.3381723,3.91827146 L12.7184593,6.47380052 C12.3233088,6.85926968 11.6838285,6.86042189 11.2807479,6.46721195 L8.67450711,3.9247929 C8.03187321,3.30572487 7.19151346,2.97111997 6.32148154,2.97111997 C5.4489221,2.97111997 4.60106916,3.30754159 3.96039524,3.92491574 C2.67871929,5.17068349 2.67871929,7.17114678 3.96586581,8.41676109 L12.00095,16.2390493 L20.041022,8.41556527 Z"}
%a
%svg{:viewBox => "0 0 24 20"}
%path{:d => "M10.1639425,10 L5.222766,17 L1.00700182,17 C0.450850071,17 0,17.4426603 0,17.9989566 L0,19.0010434 C0,19.5527519 0.45097518,20 0.990777969,20 L6,20 C6.4873848,20 6.94438517,19.7632025 7.22545179,19.3650248 L12,12.6010815 L16.7745482,19.3650248 C17.0556148,19.7632025 17.5126152,20 18,20 L23.009222,20 C23.5564136,20 24,19.5573397 24,19.0010434 L24,17.9989566 C24,17.4472481 23.5547099,17 22.9929982,17 L18.777234,17 L13.8360575,10 L18.777234,3 L22.9929982,3 C23.5491499,3 24,2.55733967 24,2.00104344 L24,0.998956561 C24,0.447248087 23.5490248,0 23.009222,0 L18,0 C17.5126152,0 17.0556148,0.236797487 16.7745482,0.634975204 L12,7.39891849 L7.22545179,0.634975204 C6.94438517,0.236797487 6.4873848,0 6,0 L0.990777969,0 C0.443586406,0 0,0.442660332 0,0.998956561 L0,2.00104344 C0,2.55275191 0.445290091,3 1.00700182,3 L5.222766,3 L10.1639425,10 Z"}
%a
%svg{:viewBox => "0 0 24 20"}
%path{:d => "M18,2.00104344 C18,2.55275191 18.4426603,3 18.9989566,3 L21,3 L21,17 L3,17 L3,3 L11.0024554,3 C11.553384,3 12,2.55733967 12,2.00104344 L12,0.998956561 C12,0.447248087 11.544239,5.68434189e-14 10.9975267,5.68434189e-14 L1.00247329,5.68434189e-14 C0.448822582,5.68434189e-14 0,0.455305576 0,0.99180311 L0,19.0081969 C0,19.5559546 0.44746922,20 1.00069463,20 L22.9993054,20 C23.5519738,20 24,19.5446944 24,19.0081969 L24,0.99180311 C24,0.444045377 23.5490248,9.4128217e-14 23.009222,9.05011945e-14 L18.990778,6.35006168e-14 C18.4435864,5.98239479e-14 18,0.442660332 18,0.998956561 L18,2.00104344 Z"}
%a.flip
%svg{:viewBox => "0 0 24 20"}
%rect{:width => "3", :height => "3", :rx => "1"}
%rect{:width => "18", :height => "3", :x => "6", :rx => "1"}
%rect{:width => "18", :height => "3", :x => "6", :y => "8.5", :rx => "1"}
%rect{:width => "18", :height => "3", :x => "6", :y => "17", :rx => "1"}
%rect{:width => "3", :height => "3", :y => "8.5", :rx => "1"}
%rect{:width => "3", :height => "3", :y => "17", :rx => "1"}
$red: #EB2045;
$grey: #0B0B0B;
$p: 12px;
$easeInBack: cubic-bezier(0.600, -0.280, 0.735, 0.045);
$easeOutBack: cubic-bezier(0.175, 0.885, 0.320, 1.275);
$easeOutCubic: cubic-bezier(0.215, 0.610, 0.355, 1.000);
*, *:before, *:after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: rgba(0,0,0,0); transform-style: preserve-3d; }
*:focus { outline: none!important; }
::selection { background: none; }
a { cursor: pointer; }
body, html { height: 100%; }
hr {
border: 0;
margin: 0;
padding: 0;
width: 100%;
height: 1px;
background: rgba($grey, .5);
}
body {
color: $grey;
font-family: "Roboto Mono", monospace;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
}
main {
perspective: 1000px;
transform-style: preserve-3d;
display: flex;
justify-content: center;
align-items: center;
align-content: center;
position: relative;
width: 100%;
height: 100%;
padding: $p;
}
.background {
background: white;
&, &:before, &:after, div {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
&:before {
content: "";
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/345377/thousand-thursday%402x.jpg') center center / cover;
filter: blur(2px);
}
div {
background: $red;
mix-blend-mode: screen;
}
&:after {
content: "";
background: rgba(black, .15);
}
}
.player {
position: relative;
z-index: 3;
width: 100%;
max-width: 320px;
.back {
opacity: 0;
}
&.playlist {
.front {
z-index: -1;
opacity: 0;
}
.back {
z-index: 1;
opacity: 1;
}
}
}
.player, .back, .front {
will-change: transform;
transform-origin: center center;
transform-style: preserve-3d;
backface-visibility: hidden;
}
.front, .back {
transition: all 500ms $easeOutBack;
background: white;
border-radius: 2px;
box-shadow: 0 0 15px rgba(mix($red, $grey), .2);
}
.back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
header {
display: flex;
align-items: center;
align-content: center;
background: rgba($grey, .1);
padding: $p;
a {
display: block;
padding: 0 5px 3px!important;
border-radius: 2px;
margin-right: $p;
background: rgba($grey, .1);
}
}
a {
display: flex;
padding: $p;
&:hover, &:focus {
background: $red;
color: white;
}
&:active {
background: $grey;
}
}
img {
display: block;
border-radius: 2px;
height: 32px;
width: 32px;
+ div {
padding-left: $p;
}
}
hr {
margin-left: $p;
width: calc(100% - #{$p*2});
background: rgba($grey, .1);
}
h3 {
margin-bottom: 4px;
font-size: 16px;
font-weight: 300;
}
h4 {
font-size: 12px;
font-weight: 500;
}
}
.art {
border-radius: 2px 2px 0 0;
display: block;
width: 100%;
}
.bar {
position: relative;
z-index: 2;
width: 100%;
height: $p;
margin-top: -$p/2;
overflow: hidden;
&:before, hr {
display: block;
position: absolute;
top: 50%;
margin-top: -1px;
left: 0;
width: 100%;
height: 2px;
}
&:before {
content: "";
background: #bbb;
}
hr {
transform: translateX(-50%);
margin-bottom: 0;
padding: 0;
border: 0;
background: $red;
&:after {
transform-origin: center center;
content: "";
display: block;
position: absolute;
right: -$p/2;
top: 50%;
margin-top: -$p/2;
width: $p;
height: $p;
background: $red;
border-radius: 2px;
}
&:hover {
background: $grey;
&:after {
background: $grey;
}
}
}
}
.controls {
display: flex;
align-items: center;
align-content: center;
width: 100%;
a {
display: block;
svg {
display: block;
width: 100%;
height: 100%;
}
&.skip {
width: 36px;
height: 20px;
}
&.play {
width: 42px;
height: 36px;
}
}
&.top {
justify-content: space-around;
padding: $p;
a {
transition: all 250ms ease-out;
will-change: transform;
svg {
fill: $grey;
}
&:hover, &:focus {
transition: all 500ms $easeOutBack;
transform: scale(1.1);
svg {
fill: $red;
}
}
&:active {
transform: scale(1);
}
}
}
&.bottom {
justify-content: space-between;
padding: $p*1.5 $p $p;
a {
width: 24px;
height: 20px;
svg {
fill: rgba($red, .25);
}
&:hover, &:focus, &.active {
svg {
fill: $red;
}
}
&.flip {
svg {
fill: rgba($grey, .25);
}
&:hover, &:focus {
svg {
fill: $grey;
}
}
}
}
}
}
.meta {
text-align: center;
time {
display: flex;
justify-content: space-between;
width: 100%;
padding: 0 $p/3;
font-size: 10px;
}
.info {
padding: $p;
}
h1 {
font-size: 20px;
font-weight: 300;
margin-bottom: $p/2;
}
h2 {
font-size: 14px;
font-weight: 500;
}
}
.pre-enter {
.background {
opacity: 0;
}
.player {
opacity: 0;
transform-origin: center top;
will-change: opacity, transform;
transform: rotateX(30deg) rotateY(-30deg) translateY(300px) translateZ(200px);
}
}
.on-enter {
.background {
transition: all 1000ms ease-out;
opacity: 1;
}
.player {
animation: rotateIn 1000ms $easeOutCubic 500ms forwards;
}
}
@keyframes rotateIn {
0% {
opacity: 0;
transform: rotateX(30deg) rotateY(-30deg) translateY(300px) translateZ(200px);
}
10% {
opacity: 1;
}
100% {
opacity: 1;
transform: none;
}
}
@media only screen and (max-height: 510px) {
.container {
transform-origin: center center;
transform: scale(0.75);
}
}
@media only screen and (min-width: 640px) {
.with-hover {
.player {
transition: all 500ms ease-out;
&:hover {
transition: all 1000ms $easeOutBack;
}
}
}
.player {
will-change: transform;
&:hover {
transform: translateZ(#{$p*5});
}
.back {
transform: rotateY(180deg);
* {
opacity: 0;
}
}
&.playlist {
.front {
transform: rotateY(180deg);
* {
opacity: 0;
}
}
.back {
transform: rotateY(0);
* {
opacity: 1;
}
}
}
}
.bar {
hr {
cursor: col-resize;
}
}
}
$("main").addClass("pre-enter").removeClass("with-hover");
setTimeout(function(){
$("main").addClass("on-enter");
}, 500);
setTimeout(function(){
$("main").removeClass("pre-enter on-enter");
setTimeout(function(){
$("main").addClass("with-hover");
}, 50);
}, 2000);
$(".flip, .back a").click(function(){
$(".player").toggleClass("playlist");
});
$(".bottom a").not(".flip").click(function(){
$(this).toggleClass("active");
});
Also see: Tab Triggers