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.halloctober.p-flex
.halloctober__banner.p-flex
h1.typo Spooky
.fog.p-circle
//- If you change the h1 word, don't forget to also replace it in the CSS before/after pseudo elements created for the text-shadow effects.
:root {
// COLOR CSS VARIABLES
--color_base: #191919; // Black
--color_pen: #fff; // White
// SIZE VARIABLES
--size: 20vmin; // Resize typo by only editing this variable
--fog: calc(var(--size) / 1.2);
--scale: 4.8; // Increase/decrease fog's size animation effect. Specially if you change the HTML h1, you might need to tweak this value.
}
// MIXINS
@mixin size($w, $h: $w) {
width: $w;
height: $h;
}
// PATTERNS
.p-flex {
display: flex;
}
.p-circle {
border-radius: 50%;
}
// LAYOUT
body {
height: 100vh;
background-color: var(--color_base);
margin: 0;
overflow: hidden;
}
::selection {
background-color: transparent;
}
.halloctober {
@include size(100%);
&__banner {
margin: auto; // Center magic after parent's display flex
padding: 3%;
position: relative; // To place fog
overflow: hidden;
}
}
// TYPOGRAPHY
.typo {
color: var(--color_pen);
cursor: default;
font-family: 'Fredoka One', sans-serif;
font-size: var(--size);
font-weight: normal;
letter-spacing: 0.1rem;
margin: auto; // Center magic
outline: none;
position: relative; // To place text-shadows
&:hover {
+ .fog {
animation-play-state: paused;
}
}
$red: #b30808;
$blue: #1A237E;
$anim: 2s ease-in-out infinite;
// Text Shadow Effects
// We add them here to improve animation's performance
&::before,
&::after {
color: transparent;
content: 'Spooky'; // Same word as in HTML h1
position: absolute;
top: 0;
left: 0;
z-index: -10;
}
// Upper Shadow
&::before {
animation: move_upper_shadow $anim;
opacity: 0;
text-shadow:
6px 0 2px rgba($red, 0.4),
12px 0 2px rgba($blue, 0.3);
}
// Bottom Shadow
&::after {
animation: move_bottom_shadow $anim;
text-shadow:
2px 4px 2px rgba($red, 0.4),
4px 8px 2px rgba($blue, 0.3);
}
transform: skew(10deg, 2deg);
animation: float $anim;
@at-root {
@keyframes move_upper_shadow {
0%, 90%, 100% {
opacity: 0;
transform: translateX(-2%);
}
30% {
opacity: 1;
transform: translateX(0);
}
}
@keyframes move_bottom_shadow {
0%, 90%, 100% {
opacity: 1;
transform: translate(0, 0);
}
30% {
opacity: 0;
transform: translateY(-3.5%);
}
}
@keyframes float {
50% {
transform: scaleY(1.01) skew(-10deg, -2deg);
}
}
}
@media (prefers-reduced-motion: reduce) {
animation: none;
transform: none;
&::before,
&::after {
animation: none;
}
}
}
.fog {
--fog_neg: calc(var(--fog) * -1);
@include size(var(--fog));
background-color: var(--color_base);
position: absolute;
top: var(--fog_neg);
left: var(--fog_neg);
transform: translate3d(0, 0, 0); // Fixes Safari mouseover flickering bug
transform-origin: 0 50%; // Fixes Firefox laggy animation bug and smooths animation across Browsers
animation: move_fog 13s 2s ease-in-out alternate infinite;
@at-root {
@keyframes move_fog {
50% {
transform: scale(var(--scale));
}
}
}
@media (prefers-reduced-motion: reduce) {
animation: none;
}
// Blurry Effect
&::after {
--blur: calc(var(--fog) * 2);
--blur_neghalf: calc(var(--blur) / -2);
--filter: calc(var(--fog) / 30);
@extend .p-circle;
@include size(var(--blur));
content: '';
background-color: var(--color_base);
filter: blur(var(--filter));
margin-top: var(--blur_neghalf);
margin-left: var(--blur_neghalf);
position: absolute;
top: 50%;
left: 50%;
}
}
/*
* PURE CSS SPOOKY TYPO
* Yet another Spooky Pen :)
*
* Experimenting with a CSS blur filter, text-shadow, and transform skew effects animated. Pause the animation on typo mouseover, not fog.
* On mobile touch typo to pause and touch anywhere else on the screen to run it again.
* Firefox mouseover/touch is not as smooth x.x
*
* Prefers-reduced-motion is applied. To test it:
* Windows 10, Settings > Ease of Access > Display > Show animations.
* MacOS, System Preferences > Accessibility > Display > Reduce motion.
*
* #halloctober
* #018 - #100DaysOfCode
* By ilithya | 2019
*/
Also see: Tab Triggers