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="frame">
<img src="http://ywahu.com/play/placeholder.png" />
<canvas id="canvas"></canvas>
</div>
<div class="window">
<div class="santa">
<div class="head">
<div class="face">
<div class="redhat">
<div class="whitepart"></div>
<div class="redpart"></div>
<div class="hatball"></div>
</div>
<div class="eyes"></div>
<div class="beard">
<div class="nouse"></div>
<div class="mouth"></div>
</div>
</div>
<div class="ears"></div>
</div>
<div class="body"></div>
</div>
</div>
<div class="fir">
<div class="fir__item"></div>
<div class="fir__item"></div>
<div class="fir__item"></div>
<div class="fir__log"></div>
<div class="orbs orbs-1"></div>
<div class="orbs orbs-2"></div>
<div class="orbs orbs-3"></div>
<div class="orbs orbs-4"></div>
</div>
<div class="message">
<h1>Wish You</h1>
<h2>Merry Christmas</h2>
<h1>And</h1>
<h2>A</h2>
<h1>Happy New Year</h1>
</div>
</div>
<div class="wrapper">
<div class="back">
</div>
<canvas id="canvas"></canvas>
</div>
body {
background: #de2f32;
margin: auto
}
.window {
width: 300px;
height: 300px;
background: #a0d5d3;
position: absolute;
margin: auto;
top: 1%;
left: 70%;
border-radius: 50%;
border: 10px solid #f8e7dc;
animation: rock;
animation-iteration-count: infinite;
animation-duration: 1s;
}
@keyframes rock {
0% {
transform: rotate(-1deg);
}
50% {
transform: rotate(2deg);
}
100% {
transform: rotate(-1deg);
}
}
@keyframes rock2 {
0% {
transform: rotate(1deg);
}
50% {
transform: rotate(-2deg);
}
100% {
transform: rotate(1deg);
}
}
.fir {
position: absolute;
margin: 0 auto;
width: 8em;
top: 40%;
left: 50px;
animation: rock;
animation-iteration-count: infinite;
animation-duration: 1s;
}
.message {
position: absolute;
left: 50%;
top: 0%;
color: #f8e7dc;
font-family: 'Mountains of Christmas';
}
.message h1 {
text-align: center;
font-style: normal;
font-size: 75px;
margin-bottom: 0;
white-space: nowrap;
animation: rock;
animation-iteration-count: infinite;
animation-duration: 1s;
}
.message h2 {
font-style: normal;
font-size: 75px;
margin-bottom: 0;
white-space: nowrap;
animation: rock2;
animation-iteration-count: infinite;
animation-duration: 1s;
}
/*credits:
pure css laughing santa from: https://codepen.io/Alireza29675/pen/KwgwMy
pure css Tree with glowing orbs from:
https://codepen.io/martinwolf/pen/DyrwK/
snowing animation using JS from:
https://codepen.io/jywahu/pen/RrGKvw
*/
var makeitSnow = function() {
//canvas init
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
//canvas dimensions
var W = $(".frame").innerWidth();
var H = $(".frame").innerHeight();
canvas.width = W;
canvas.height = H;
//snowflake particles
var mp = 100; //max particles
var particles = [];
for (var i = 0; i < mp; i++) {
particles.push({
x: Math.random() * W, //x-coordinate
y: Math.random() * H, //y-coordinate
r: Math.random() * 4 + 1, //radius
d: Math.random() * mp //density
})
}
//Lets draw the flakes
function draw() {
ctx.clearRect(0, 0, W, H);
ctx.fillStyle = "rgba(255, 255, 255, 0.8)";
ctx.beginPath();
for (var i = 0; i < mp; i++) {
var p = particles[i];
ctx.moveTo(p.x, p.y);
ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2, true);
}
ctx.fill();
update();
}
//Function to move the snowflakes
//angle will be an ongoing incremental flag. Sin and Cos functions will be applied to it to create vertical and horizontal movements of the flakes
var angle = 0;
function update() {
angle += 0.01;
for (var i = 0; i < mp; i++) {
var p = particles[i];
//Updating X and Y coordinates
//We will add 1 to the cos function to prevent negative values which will lead flakes to move upwards
//Every particle has its own density which can be used to make the downward movement different for each flake
//Lets make it more random by adding in the radius
p.y += Math.cos(angle + p.d) + 1 + p.r / 2;
p.x += Math.sin(angle) * 2;
//Sending flakes back from the top when it exits
//Lets make it a bit more organic and let flakes enter from the left and right also.
if (p.x > W + 5 || p.x < -5 || p.y > H) {
if (i % 3 > 0) //66.67% of the flakes
{
particles[i] = {
x: Math.random() * W,
y: -10,
r: p.r,
d: p.d
};
} else {
//If the flake is exitting from the right
if (Math.sin(angle) > 0) {
//Enter from the left
particles[i] = {
x: -5,
y: Math.random() * H,
r: p.r,
d: p.d
};
} else {
//Enter from the right
particles[i] = {
x: W + 5,
y: Math.random() * H,
r: p.r,
d: p.d
};
}
}
}
}
}
//animation loop
setInterval(draw, 33);
}
window.onload = makeitSnow();
Also see: Tab Triggers