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{:autoplay => ""}
%source{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/142927/intro.mp3", :type => "audio/mpeg"}
.wrapper
.composition
.scene.scene--1
.shooting-star
.gamefreak-logo
.gamefreak
.star-shower-mask
.star-shower--light
.star-shower--dark
.scene.scene--2
%section.opponent.jigglypuff-wrapper
%figure.jigglypuff
%figure.jigglypuff--flinch
%figure.jigglypuff--tackle
%section.opponent.nidorino-wrapper
%figure.nidorino
%figure.nidorino--flinch
%figure.nidorino--tackle
%section.gengar-wrapper
%figure.gengar
%figure.gengar--scratch1
%figure.gengar--scratch2
.scene.scene--3
.logo-wrapper
%figure.pokemon-logo
%span CSS Edition
/*
DISCLAIMER: Works best in Chrome! Due to the changes in Chrome's Autoplay Policy, it's likely that you won't hear the nostalgic 8-bit music, though :( You can read up on the details of this over at Google's Developer Blog (https://developers.google.com/web/updates/2017/09/autoplay-policy-changes).
If you want to revisit those settings in your browser you can do this by making changes to the respective Chrome flag here: chrome://flags/#autoplay-policy
*/
// Feel free to play around with the following settings!
$version: "blue"; // Can be "blue" or "red"
$color: false;
$upscale: true;
/*
Due to performance issues I had to cheat a bit and include the pixel maps as precompiled file, if you want to take a look at the uncompressed/uncompiled version you can do so on Pastebin (https://pastebin.com/QvUwGdNp). The technique used, is the same as in my previous pen (https://codepen.io/kai/pen/eWMMmL) ⚡🐭. If you want to read up on how to do pixel art with Sass, you should definitely check Una Kravet's fantastic blogpost (http://una.im/sass-pixel-art) 🙏.
To generate the pixel maps in a more convenient way, Alex (https://twitter.com/cilice) invested some of his spare time to create a generator that does basically everything for you: https://pokedecss-generator.glitch.me 🎉.
*/
$asset-path : "https://s3-us-west-2.amazonaws.com/s.cdpn.io/142927";
$scene-1-length: 4.8;
$scene-2-length: 9.4;
@import url("#{$asset-path}/pokemon-pixelart-precompiled.css");
@font-face {
font-family:'Pokemon GB';
src: url('#{$asset-path}/Pokemon_GB.eot?#iefix') format('embedded-opentype'),
url('#{$asset-path}/Pokemon_GB.woff') format('woff'),
url('#{$asset-path}/Pokemon_GB.ttf') format('truetype'),
url('#{$asset-path}/Pokemon_GB.svg#PokemonGB') format('svg');
font-weight: 400;
}
audio { visibility: hidden; }
.wrapper {
background: black;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.composition {
position: relative;
width: 192px;
height: 144px;
overflow: hidden;
@if $upscale == true {
transform: scale(4);
}
}
.scene {
position: absolute;
background: #F9F9F9;
top: 20px;
bottom: 20px;
left: 0;
right: 0;
@if $color == false {
filter: grayscale(100);
}
&--1 {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
animation: fade 0s ($scene-1-length + 0.5)+s linear reverse;
animation-fill-mode: forwards;
.shooting-star {
width: 16px;
height: 16px;
position: absolute;
right: -16px;
top: -36px;
animation: starswipe 0.9s linear;
z-index: 3;
}
.gamefreak-logo {
position: relative;
width: 11px;
height: 23px;
margin-bottom: 8px;
animation: shine-logo 0.5s 1s steps(2);
z-index: 2;
}
.gamefreak {
position: relative;
width: 80px;
height: 8px;
animation: shine-title 0.5s 0.7s steps(1);
z-index: 2;
}
.star-shower-mask {
position: absolute;
width: 80px;
top: 70px;
bottom: 0;
overflow: hidden;
height: 34px;
}
.star-shower--light {
position: absolute;
transform: translateY(-47px);
width: 81px;
height: 47px;
animation: star-shower 2.8s 1.7s linear;
animation-fill-mode: forwards;
}
.star-shower--dark {
position: absolute;
transform: translateY(-47px);
width: 81px;
height: 47px;
animation: star-shower 2.8s 1.7s linear, fade 0.1s linear infinite;
animation-fill-mode: forwards;
}
}
&--2 {
overflow: hidden;
opacity: 0;
z-index: 2;
animation: fade 0.1s $scene-1-length+s;
animation-fill-mode: forwards;
&:before {
content: "";
position: absolute;
width: 100%;
height: 100%;
background: #FEFEFE;
z-index: 1;
opacity: 0;
animation: fade 0.8s ($scene-1-length + $scene-2-length - 0.8)+s steps(6);
animation-fill-mode: forwards;
}
.gengar-wrapper {
width: 58px;
height: 54px;
position: absolute;
bottom: 0;
right: 0;
animation: gg-intro 1.2s $scene-1-length+s linear, gg-tackle 1.2s ($scene-1-length + 4.2)+s linear;
animation-fill-mode: forwards;
.gengar {
position: absolute;
width: 58px;
height: 54px;
animation: fade 0s ($scene-1-length + 3.75)+s linear reverse, fade 0s ($scene-1-length + 5.6)+s linear;
animation-fill-mode: forwards;
}
.gengar--scratch1 {
position: absolute;
width: 58px;
height: 54px;
opacity: 0;
transform: translateX(-10px);
animation: fade 0s ($scene-1-length + 3.75)+s linear, fade 0s ($scene-1-length + 4.2)+s linear reverse;
animation-fill-mode: forwards;
}
.gengar--scratch2 {
position: absolute;
width: 58px;
height: 54px;
opacity: 0;
animation: fade 0s ($scene-1-length + 4.2)+s linear, fade 0s ($scene-1-length + 5.6)+s linear reverse;
animation-fill-mode: forwards;
}
}
.opponent {
position: absolute;
bottom: 0;
left: 0;
animation: op-intro 1.2s $scene-1-length+s linear, op-bounce-sm 1s ($scene-1-length + 1.2)+s 2 linear, op-flinch 0.8s ($scene-1-length + 4.6)+s linear, op-bounce-bg 1s ($scene-1-length + 6.4)+s linear, op-slam 0.8s ($scene-1-length + 8.6)+s linear;
animation-fill-mode: forwards;
}
.jigglypuff-wrapper {
width: 35px;
height: 35px;
@if $version == "red" {
display: none;
}
.jigglypuff {
width: 35px;
height: 35px;
position: absolute;
animation: fade 0s ($scene-1-length + 4.6)+s linear reverse, fade 0s ($scene-1-length + 6.4)+s linear, fade 0s ($scene-1-length + 8)+s linear reverse;
animation-fill-mode: forwards;
}
.jigglypuff--flinch {
width: 35px;
height: 35px;
position: absolute;
opacity: 0;
animation: fade 0s ($scene-1-length + 4.6)+s linear, fade 0s ($scene-1-length + 6.4)+s linear reverse, fade 0s ($scene-1-length + 8)+s linear, fade 0s ($scene-1-length + 8.6)+s linear reverse;
animation-fill-mode: forwards;
}
.jigglypuff--tackle {
width: 48px;
height: 48px;
position: absolute;
opacity: 0;
animation: fade 0s ($scene-1-length + 8.6)+s linear;
animation-fill-mode: forwards;
}
}
.nidorino-wrapper {
width: 44px;
height: 40px;
@if $version == "blue" {
display: none;
}
.nidorino {
width: 44px;
height: 40px;
position: absolute;
animation: fade 0s ($scene-1-length + 4.6)+s linear reverse, fade 0s ($scene-1-length + 6.4)+s linear, fade 0s ($scene-1-length + 8)+s linear reverse;
animation-fill-mode: forwards;
}
.nidorino--flinch {
width: 44px;
height: 40px;
position: absolute;
opacity: 0;
animation: fade 0s ($scene-1-length + 4.6)+s linear, fade 0s ($scene-1-length + 6.4)+s linear reverse, fade 0s ($scene-1-length + 8)+s linear, fade 0s ($scene-1-length + 8.6)+s linear reverse;
animation-fill-mode: forwards;
}
.nidorino--tackle {
width: 44px;
height: 44px;
position: absolute;
opacity: 0;
animation: fade 0s ($scene-1-length + 8.6)+s linear;
animation-fill-mode: forwards;
}
}
}
&--3 {
opacity: 0;
z-index: 3;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
animation: fade 0s ($scene-1-length + $scene-2-length)+s linear;
animation-fill-mode: forwards;
.logo-wrapper {
position: absolute;
top: 0;
}
.pokemon-logo {
width: 128px;
height: 49px;
animation: logo-entrance 0.3s ($scene-1-length + $scene-2-length + 0.8)+s linear;
animation-fill-mode: forwards;
transform: translateX(-3px) translateY(-50px);
}
span {
font-family:'Pokemon GB', monospace;
font-size: 8px;
animation: version-entrance 0.5s ($scene-1-length + $scene-2-length + 1.5)+s linear;
animation-fill-mode: forwards;
display: block;
transform: translateX(150px);
}
}
}
@keyframes op-intro {
from { transform: translateX(10px) translateY(8px); }
to { transform: translateX(110px) translateY(8px); }
}
@keyframes op-bounce-sm {
0% { transform: translateX(110px) translateY(8px); }
25% { transform: translateX(115px) translateY(5px); }
50% { transform: translateX(120px) translateY(8px); }
75% { transform: translateX(115px) translateY(5px); }
100% { transform: translateX(110px) translateY(8px); }
}
@keyframes op-flinch {
0% { transform: translateX(110px) translateY(8px); }
50% { transform: translateX(120px) translateY(-15px); }
100% { transform: translateX(130px) translateY(8px); }
}
@keyframes op-bounce-bg {
0% { transform: translateX(130px) translateY(8px); }
25% { transform: translateX(125px) translateY(-5px); }
50% { transform: translateX(120px) translateY(8px); }
75% { transform: translateX(125px) translateY(-5px); }
100% { transform: translateX(130px) translateY(8px); }
}
@keyframes op-slam {
from { transform: translateX(125px) translateY(5px); }
to { transform: translateX(70px) translateY(-30px); }
}
@keyframes gg-intro {
from { transform: translateX(-10px); }
to { transform: translateX(-100px); }
}
@keyframes gg-tackle {
0% { transform: translateX(-100px); }
40% { transform: translateX(-70px); }
75% { transform: translateX(-70px); }
100% { transform: translateX(-100px); }
}
@keyframes fade {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes starswipe {
from { transform: translateX(0) translateY(0); }
to { transform: translateX(-228px) translateY(180px); }
}
@keyframes shine-logo {
0% { opacity: 1; }
50% { opacity: 0.35; }
100% { opacity: 1; }
}
@keyframes shine-title {
0% { opacity: 1; }
50% { opacity: 0.1; }
100% { opacity: 1; }
}
@keyframes star-shower {
from { transform: translateY(-47px); }
to { transform: translateY(47px); }
}
@keyframes logo-entrance {
from { transform: translateX(-3px) translateY(-50px); }
to { transform: translateX(-3px) translateY(20px); }
}
@keyframes version-entrance {
from { transform: translateY(25px) translateX(150px); }
to { transform: translateY(25px) translateX(0); }
}
Also see: Tab Triggers