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.
- const WORD = "Jhey Tompkins"
.text-grid
.avatar-ring
img(src="https://assets.codepen.io/605876/me--noticing.png")
img(src="https://assets.codepen.io/605876/me--standing.png")
- let t = 0
while t < 51
if (t === 25)
h1.text-grid__main(data-splitting="")= WORD
else
h1(aria-hidden="true")= WORD
- t++
button
svg(viewBox="0 0 512 512" title="restart")
path(d="M500.33 0h-47.41a12 12 0 0 0-12 12.57l4 82.76A247.42 247.42 0 0 0 256 8C119.34 8 7.9 119.53 8 256.19 8.1 393.07 119.1 504 256 504a247.1 247.1 0 0 0 166.18-63.91 12 12 0 0 0 .48-17.43l-34-34a12 12 0 0 0-16.38-.55A176 176 0 1 1 402.1 157.8l-101.53-4.87a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12h200.33a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12z")
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@800&display=swap')
*
box-sizing border-box
:root
--stroke hsl(0, 0%, 50%)
--shadow-5 'hsl(%s, 70%, 52%, 0.5)' % var(--hue, 10)
--shadow-75 'hsl(%s, 70%, 52%, 0.75)' % var(--hue, 10)
body
font-family 'Nunito', sans-serif
min-height 100vh
text-transform uppercase
overflow hidden
background hsl(0, 10%, 10%)
h1
margin 0
white-space nowrap
font-size clamp(2rem, 10vmin, 5rem)
line-height 0.8
color transparent
z-index -1
[aria-hidden]
user-select none
-webkit-text-stroke 2px var(--stroke)
opacity 0
.char
-webkit-text-stroke 2px var(--stroke)
display inline-block
.text-grid
display grid
grid-gap 0 4vmin
grid-template-columns repeat(3, auto)
position fixed
top 50%
left 50%
transform translate(-50%, -45%)
&__main
z-index 2
.char
--drop 0
will-change filter
&--on
filter drop-shadow(0 calc(var(--drop, 0) * -2.5px) calc(var(--drop, 0) * 2.5px) hsl(0, 10%, 0%)) drop-shadow(0 0 calc(var(--drop, 0) * 5px) var(--shadow-5)) drop-shadow(0 0 calc(var(--drop, 0) * 10px) var(--shadow-5)) drop-shadow(0 0 calc(var(--drop, 0) * 0.5px) var(--shadow-75)) brightness(calc(1 + (var(--drop) * 0.2)))
.avatar-ring
position absolute
top 50%
left 50%
width 50vmin
height 50vmin
max-width 280px
max-height 280px
border 10px solid var(--stroke)
border-radius 50%
background 'hsl(%s, 30%, 20%)' % var(--hue)
transform translate(-50%, -80%) scale(0)
overflow hidden
&:after
content ''
height 100%
width 100%
// background hsla(0, 0%, 0%, 0.45)
position absolute
top 65%
left 50%
transform translate(-50%, 0%)
img
position absolute
top 50%
left 50%
width 150%
transform translate(-50%, -50%)
filter grayscale(0)
&:hover img:nth-of-type(2)
display none
button
height 48px
width 48px
position fixed
right 1rem
bottom 1rem
appearance none
border none
background transparent
transition transform 0.2s
outline transparent
&:active
transform scale(0.75)
svg
height 2rem
width 2rem
fill white
.char--on
animation flicker 1s infinite
@keyframes flicker
50%
--drop 0 !important
--stroke black !important
import Splitting from 'https://cdn.skypack.dev/splitting'
import gsap from 'https://cdn.skypack.dev/gsap'
import { RoughEase } from 'https://cdn.skypack.dev/gsap/EasePack'
gsap.registerPlugin(RoughEase)
Splitting()
let COLOR
let FLICKER
let MAIN
const setColor = () => {
const hue = Math.random() * 360
gsap.set(document.documentElement, {
'--hue': hue,
})
COLOR = `hsl(${hue}, 65%, 80%)`
}
const CHARS = gsap.utils.toArray('.text-grid__main .char')
const STAGGER = 0.025
const SPEED = 0.2
const RESET = () => {
if (MAIN) MAIN.kill()
window.FLICKER = FLICKER =
CHARS[Math.floor(Math.random() * 'Jhey Tompkins'.split('').length)]
setColor()
gsap.set(['[aria-hidden]', '.char'], {
opacity: 0,
})
gsap.set('.avatar-ring', {
clearProps: 'all',
})
gsap.set('.avatar-ring', {
scale: 0,
transformOrigin: '50% 65%',
})
gsap.set('.char', {
color: 'transparent',
stroke: 'hsl(0, 0%, 50%)',
scale: 1,
})
gsap.set('img', {
yPercent: 100,
})
gsap.set(CHARS, {
attr: {
class: 'char',
},
})
}
const REVEAL = () =>
gsap
.timeline()
.set('.char', {
'--drop': 0,
'--stroke': 'hsl(0, 0%, 50%)',
})
.to('.char', {
stagger: STAGGER,
opacity: 1,
duration: SPEED,
})
.to(
'.char',
{
stagger: STAGGER,
color: COLOR,
duration: SPEED,
'--stroke': COLOR,
},
'<+0.4'
)
.to('[aria-hidden]', {
opacity: 1,
duration: STAGGER,
delay: gsap.utils.distribute({
base: 0,
amount: SPEED,
grid: 'auto',
from: 'center',
}),
repeat: 1,
yoyo: true,
})
.to(
'.avatar-ring',
{
scale: 1,
duration: SPEED,
},
'<'
)
.to(
'img',
{
yPercent: -50,
duration: SPEED,
},
`>-${SPEED * 0.5}`
)
.set('.text-grid__main .char', {
attr: {
class: 'char char--on',
},
})
.to('.text-grid__main .char', {
'--drop': 1,
duration: SPEED,
})
.add(
gsap
.timeline({
repeat: -1,
delay: gsap.utils.random(1, 3),
repeatDelay: gsap.utils.random(5, 10),
})
.to(FLICKER, {
opacity: 0.3,
yoyo: true,
duration: 0.5,
repeatDelay: 0.1,
ease: `rough({ template: power1.out, strength: 2, points: 50, taper: 'none', randomize: true, clamp: true})`,
repeat: 1,
})
)
RESET()
MAIN = REVEAL()
document.querySelector('button').addEventListener('click', () => {
RESET()
MAIN = REVEAL()
})
Also see: Tab Triggers