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="m-posterContainer">
<input type="checkbox" class="a-toggle" id="posterCheck">
<div class="o-poster">
<div class="m-frame">
<div class="m-poster">
<img class="a-poster" src="https://upload.wikimedia.org/wikipedia/en/8/88/Donkey_Kong_Jr_Math_box.jpg" alt="donkey kong first poster">
</div>
</div>
<div class="m-lightToggle">
<label class="a-wire" for="posterCheck"></label>
</div>
</div>
</div>
<div class="m-posterContainer">
<input type="checkbox" class="a-toggle" id="posterCheck2" checked>
<div class="o-poster">
<div class="m-frame">
<div class="m-poster">
<img class="a-poster" src="https://upload.wikimedia.org/wikipedia/pt/2/2a/Donkey-Kong-capa.PNG" alt="donkey kong first poster">
</div>
</div>
<div class="m-lightToggle">
<label class="a-wire" for="posterCheck2"></label>
</div>
</div>
</div>
<div class="m-posterContainer">
<input type="checkbox" class="a-toggle" id="posterCheck3">
<div class="o-poster">
<div class="m-frame">
<div class="m-poster">
<img class="a-poster" src="https://upload.wikimedia.org/wikipedia/en/2/27/Dk3_arcade.jpg" alt="donkey kong first poster">
</div>
</div>
<div class="m-lightToggle">
<label class="a-wire" for="posterCheck3"></label>
</div>
</div>
</div>
body {
min-height: 100vh;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
background-color: #bf360c;
background-image: url('data:image/svg+xml,%3Csvg width="42" height="44" viewBox="0 0 42 44" xmlns="http://www.w3.org/2000/svg"%3E%3Cg id="Page-1" fill="none" fill-rule="evenodd"%3E%3Cg id="brick-wall" fill="%23000000" fill-opacity="0.2"%3E%3Cpath d="M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E'), radial-gradient(transparent 0, #000000dd 100%);
background-attachment: scroll;
&:after {
content: "";
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: radial-gradient(
ellipse at top,
transparent 0,
rgba(#000, 0.8) 70%
);
pointer-events: none;
mix-blend-mode: lighten;
}
}
.a-message {
flex: 1 0 100%;
text-align: center;
font-family: monospace;
font-size: 16px;
font-weight: 700;
color: white;
text-shadow: 1px 1px 0 black;
margin: 16px 0;
}
.m-posterContainer {
margin: 0px 60px 140px;
}
.a-toggle {
display: none;
}
.o-poster {
position: relative;
}
.m-frame {
padding: 16px;
background-color: #4e342e;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='#000000' fill-opacity='0.1'%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");
box-shadow: 0 10px 16px 2px rgba(#000, 0.8);
.a-toggle:checked + .o-poster & {
animation: frameLightFlickering 7s infinite;
}
}
.m-poster {
box-shadow: inset 0 0 8px 0;
}
.a-poster {
filter: brightness(0.4);
height: 340px;
&::selection {
background: transparent;
color: transparent;
}
.a-toggle:checked + .o-poster & {
//filter: brightness(1);
animation-name: posterLightFlickering;
animation-iteration-count: infinite;
}
.m-posterContainer:nth-of-type(1) & {
animation-duration: 7s;
}
.m-posterContainer:nth-of-type(2) & {
animation-duration: 10s;
}
.m-posterContainer:nth-of-type(3) & {
animation-duration: 5s;
}
}
.m-lightToggle {
filter: drop-shadow(0 6px 2px);
position: absolute;
top: 100%;
left: 85%;
}
.a-wire {
display: block;
width: 2px;
height: 80px;
background-color: #333;
position: relative;
cursor: pointer;
transition: height 0.2s ease;
transform-origin: center top;
transform: rotate(-0.5deg);
animation: wirePendulum 2s infinite;
.m-posterContainer:nth-of-type(1) & {
animation-delay: 3s;
}
.m-posterContainer:nth-of-type(2) & {
}
.m-posterContainer:nth-of-type(3) & {
animation-delay: 1;
}
&:after {
content: "";
width: 16px;
height: 16px;
border-radius: 8px;
background-color: transparent;
box-shadow: inset 0 0 3px 1px, inset 0 0 0 3px white;
display: block;
position: absolute;
top: 100%;
left: -7px;
}
&:active {
height: 88px;
}
}
@keyframes posterLightFlickering {
0%,
14%,
14.2%,
49.6%,
51%,
52%,
52.2%,
100% {
filter: brightness(1);
}
14.1%,
49.7%,
52.1% {
filter: brightness(0.4);
}
}
@keyframes frameLightFlickering {
0%,
14%,
14.2%,
49.6%,
51%,
52%,
52.2%,
100% {
box-shadow: 0 10px 16px 2px rgba(#000, 0.8), 0 0 12px rgba(#000, 0.8),
0 0 100px 0 rgba(#ffffee, 0.4);
}
14.1%,
49.7%,
52.1% {
box-shadow: 0 10px 16px 2px rgba(#000, 0.8);
}
}
@keyframes wirePendulum {
0%,
100% {
transform: rotate(-0.5deg);
}
50% {
transform: rotate(0.5deg);
}
}
Also see: Tab Triggers