<a
class="bear-link"
href="https://twitter.com/intent/follow?screen_name=jh3yy"
target="_blank"
rel="noreferrer noopener"
>
<svg
class="w-9"
viewBox="0 0 969 955"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<circle
cx="161.191"
cy="320.191"
r="133.191"
stroke="currentColor"
stroke-width="20"
></circle>
<circle
cx="806.809"
cy="320.191"
r="133.191"
stroke="currentColor"
stroke-width="20"
></circle>
<circle
cx="695.019"
cy="587.733"
r="31.4016"
fill="currentColor"
></circle>
<circle
cx="272.981"
cy="587.733"
r="31.4016"
fill="currentColor"
></circle>
<path
d="M564.388 712.083C564.388 743.994 526.035 779.911 483.372 779.911C440.709 779.911 402.356 743.994 402.356 712.083C402.356 680.173 440.709 664.353 483.372 664.353C526.035 664.353 564.388 680.173 564.388 712.083Z"
fill="currentColor"
></path>
<rect
x="310.42"
y="448.31"
width="343.468"
height="51.4986"
fill="#FF1E1E"
></rect>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M745.643 288.24C815.368 344.185 854.539 432.623 854.539 511.741H614.938V454.652C614.938 433.113 597.477 415.652 575.938 415.652H388.37C366.831 415.652 349.37 433.113 349.37 454.652V511.741L110.949 511.741C110.949 432.623 150.12 344.185 219.845 288.24C289.57 232.295 384.138 200.865 482.744 200.865C581.35 200.865 675.918 232.295 745.643 288.24Z"
fill="currentColor"
></path>
</svg>
</a>
<header>
<div class="header__content">
<h1><span>CSS Pro</span>Take a scroll with style.</h1>
</div>
<img
src="https://images.unsplash.com/photo-1532356884227-66d7c0e9e4c2?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
alt=""
/>
</header>
<main>
<section>
<div>
<p data-splitting="" aria-hidden="true">
We refuse to accept a future where our CSS is painful, weak, and
boring.
</p>
<p class="sr-only">
We refuse to accept a future where our CSS is painful, weak, and
boring.
</p>
</div>
</section>
<section>
<p class="squisher">
<span aria-hidden="true">Check it.</span
><span aria-hidden="true">Check it.</span><span>Check it.</span>
</p>
</section>
</main>
<footer>2024 © @jh3yy ʕ·ᴥ· ʔ</footer>
@import url('https://fonts.googleapis.com/css2?family=Enriqueta:wght@400;500;600;700&display=swap');
@import 'normalize.css';
@property --sleep {
inherits: true;
syntax: '<number>';
initial-value: 0;
}
*,
*:after,
*:before {
box-sizing: border-box;
}
:root {
--sleep-buffer: 200;
}
[data-theme='light'],
html {
--strength: 0.15;
color-scheme: light only;
}
@media (prefers-color-scheme: dark) {
html {
--strength: 1;
color-scheme: dark only;
}
}
[data-theme='dark'] {
--strength: 1;
color-scheme: dark only;
}
.word {
white-space: nowrap;
}
header img {
position: absolute;
top: 0%;
z-index: -1;
left: 0;
width: 80vh;
min-width: 500px;
translate: -30% 0%;
aspect-ratio: 1;
object-fit: cover;
filter: grayscale(1) blur(0px);
mask: linear-gradient(-45deg, #0000, #000, #0000),
linear-gradient(-90deg, #0000, #000, #0000),
radial-gradient(circle at center, #000, hsl(0 0% 100% / 0.5), #0000 70%);
mask-composite: intersect;
}
body {
display: flex;
flex-direction: column;
place-items: center;
min-height: 100vh;
font-family: 'Enriqueta', serif;
overflow-x: hidden;
background: linear-gradient(
-30deg,
transparent,
hsl(0 0% 0% / var(--strength, 0.05)) 10% 15%,
transparent 30% 50%,
hsl(0 0% 0% / var(--strength, 0.05)) 70% 75%,
transparent
), canvas;
background-attachment: fixed;
}
body::before {
--size: 40px;
--line: color-mix(in lch, canvasText, transparent 85%);
content: '';
height: 100vh;
width: 100vw;
position: fixed;
background: linear-gradient(
90deg,
var(--line) 1px,
transparent 1px var(--size)
)
50% 50% / var(--size) var(--size),
linear-gradient(var(--line) 1px, transparent 1px var(--size)) 50% 50% /
var(--size) var(--size);
mask: linear-gradient(-25deg, transparent 30%, white);
top: 0;
transform-style: flat;
pointer-events: none;
z-index: -1;
}
main {
width: 100%;
}
header {
min-height: 10vh;
display: flex;
place-items: center;
width: 58ch;
text-align: right;
max-width: calc(100% - 2rem);
padding: 1rem;
position: relative;
}
header h1 {
width: auto;
font-size: clamp(2.5rem, 4vw + 1rem, 8rem);
font-weight: 400;
margin: 0;
text-wrap: balance;
display: grid;
translate: 0 -0.4em;
line-height: 1;
}
header h1 span {
font-size: 0.4em;
font-weight: 600;
font-family: 'SF Pro Text', 'SF Pro Icons', 'AOS Icons', 'Helvetica Neue',
Helvetica, Arial, sans-serif, system-ui;
color: hsl(15 80% 50%);
}
@media (prefers-color-scheme: dark) {
html:not([data-theme='light']) header img {
filter: grayscale(1) blur(0);
}
}
section:first-of-type p {
max-width: calc(100vw - 2rem);
width: 34ch;
text-align: center;
font-size: clamp(1.5rem, 2.25vw + 1rem, 6rem);
font-weight: 400;
}
section:last-of-type {
height: 100vh;
display: grid;
place-items: center;
font-size: clamp(2.5rem, 6vw + 1rem, 8rem);
}
p {
margin: 0;
}
.squisher {
display: inline-block;
position: relative;
line-height: 0.85;
}
.squisher > [aria-hidden='true'] {
position: absolute;
inset: 0;
}
.squisher span:nth-of-type(1) {
transform-origin: 50% 100%;
}
.squisher span:nth-of-type(2) {
transform-origin: 50% 0;
}
.squisher span:nth-of-type(3) {
color: transparent;
}
section:first-of-type div {
position: sticky;
height: 100vh;
top: 0;
display: grid;
place-items: center;
}
footer {
padding: 2rem;
}
.bear-link {
color: canvasText;
position: fixed;
top: 1rem;
left: 1rem;
width: 48px;
aspect-ratio: 1;
display: grid;
place-items: center;
opacity: 0.8;
}
:where(.x-link, .bear-link):is(:hover, :focus-visible) {
opacity: 1;
}
.bear-link svg {
width: 75%;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
.char {
display: inline-block;
}
div.tp-dfwv {
position: fixed;
}
@supports (animation-timeline: scroll()) {
[data-entity='character'] section:first-of-type {
/* min-height: 200vh; */
view-timeline: --section;
height: calc(
100vh + (var(--scroll-padding) * 2px) + (var(--sleep-buffer) * 1px) +
(
(
var(--char-total) *
(var(--pixels-per-character) * var(--delay-multiplier))
) * 1px
)
);
}
[data-entity='word'] section:first-of-type {
/* min-height: 200vh; */
view-timeline: --section;
height: calc(
100vh + (var(--scroll-padding) * 2px) + (var(--sleep-buffer) * 1px) +
(
(
var(--word-total) *
(var(--pixels-per-character) * var(--delay-multiplier))
) * 1px
)
);
}
[data-entity='character'] .char {
/* To calculate a delay, use "sin" against the entire range of the start? */
/* calc(sin((var(--index) / 12) * 45deg) * 0.475s); */
--start: calc(
100vh + (var(--scroll-padding) * 1px) +
(
(
sin((var(--char-index) / var(--char-total)) * 45deg) *
(
var(--char-total) *
(var(--pixels-per-character) * var(--delay-multiplier))
)
) * 1px
)
);
--end: calc(var(--start) + (var(--pixels-per-character) * 1px));
animation: drop both linear;
animation-timeline: --section;
animation-range: var(--start) var(--end);
}
[data-entity='word'] .word {
/* To calculate a delay, use "sin" against the entire range of the start? */
/* calc(sin((var(--index) / 12) * 45deg) * 0.475s); */
display: inline-block;
--start: calc(
100vh + (var(--scroll-padding) * 1px) +
(
(
sin((var(--word-index) / var(--word-total)) * 45deg) *
(
var(--word-total) *
(var(--pixels-per-character) * var(--delay-multiplier))
)
) * 1px
)
);
--end: calc(var(--start) + (var(--pixels-per-character) * 1px));
animation: drop both linear;
animation-timeline: --section;
animation-range: var(--start) var(--end);
}
@keyframes drop {
0% {
translate: calc(var(--x, 0) * 1%) calc(var(--y, 0) * 1%);
filter: blur(calc(var(--blur, 6) * 1px));
opacity: 0;
}
}
section:has(.squisher) {
view-timeline-name: --squisher;
}
.squisher span:nth-of-type(2) {
--from: 1 1;
--to: 1 0;
}
.squisher span:nth-of-type(1) {
--from: 1 0;
--to: 1 1;
}
.squisher span[aria-hidden='true'] {
animation: scale both ease-in-out;
animation-timeline: --squisher;
animation-range: entry calc(100% - 10vh) entry 100%;
}
@keyframes scale {
to {
scale: 10;
}
}
@keyframes scale {
0% {
scale: var(--from);
}
100% {
scale: var(--to);
}
}
header {
view-timeline-name: --header;
}
.header__content {
translate: 0 calc(50vh - 50%);
}
header :where(img, h1) {
animation: fade-away both linear;
animation-timeline: --header;
animation-range: exit 100% exit 150%;
}
body {
timeline-scope: --section;
}
header img {
--y: 0%;
position: fixed;
animation: fade-away both linear;
animation-timeline: --section;
animation-range: entry 90% entry 120%;
}
@keyframes fade-away {
to {
transform: translateY(var(--y, -50%));
opacity: 0;
filter: grayscale(1) blur(10px);
}
}
.word:last-of-type {
position: relative;
}
[data-entity='word'] .words {
--sleep-start: calc(
100vh + (var(--scroll-padding) * 1px) +
(var(--pixels-per-character) * 1px) +
(
sin(45deg) *
(
var(--word-total) *
(var(--pixels-per-character) * var(--delay-multiplier))
) * 1px
)
);
}
[data-entity='character'] .words {
--sleep-start: calc(
100vh + (var(--scroll-padding) * 1px) +
(var(--pixels-per-character) * 1px) +
(
sin(45deg) *
(
var(--char-total) *
(var(--pixels-per-character) * var(--delay-multiplier))
) * 1px
)
);
}
.words {
animation: sleep both steps(1);
animation-timeline: --section;
animation-range: var(--sleep-start)
calc(var(--sleep-start) + (var(--sleep-buffer) * 1px));
}
@keyframes sleep {
100% {
--sleep: 1;
}
}
.zzz {
transition: opacity 0.5s;
opacity: var(--sleep);
}
[data-entity='character'] .word:not(:last-of-type),
[data-entity='word'] .word:not(:last-of-type) .char {
transition: opacity 0.5s;
opacity: calc(1 - (var(--sleep) * 0.75));
}
.word:last-of-type {
position: relative;
}
.z {
content: 'Z';
position: absolute;
bottom: 2ex;
font-size: 0.5em;
color: red;
left: 100%;
font-weight: 900;
font-family: sans-serif;
transform-origin: 0 100%;
animation: snore 4s calc(var(--i) * (4 / 3) * -1s) ease-in-out infinite;
}
.z:nth-of-type(1) {
--r: 10deg;
}
.z:nth-of-type(2) {
--r: -5deg;
}
.z:nth-of-type(3) {
--r: -10deg;
}
@keyframes snore {
0% {
scale: 0;
}
25% {
scale: 1;
translate: 0 -50%;
rotate: var(--r, 20deg);
}
85% {
opacity: 1;
}
100% {
rotate: var(--r, 20deg);
opacity: 0;
scale: 1;
translate: 0 -50%;
transform: translateX(220%);
}
}
}
::view-transition-old(root) {
animation: none;
z-index: -1;
}
::view-transition-new(root) {
animation: unclip 1s;
clip-path: polygon(-100vmax 100%, 100% 100%, 100% -100vmax);
}
@keyframes unclip {
0% {
clip-path: polygon(100% 100%, 100% 100%, 100% 100%);
}
}
import { Pane } from 'https://cdn.skypack.dev/tweakpane'
import Splitting from 'https://cdn.skypack.dev/splitting'
const result = Splitting()
document.documentElement.style.setProperty(
'--char-total',
result[0].chars.length
)
document.documentElement.style.setProperty(
'--word-total',
result[0].words.length
)
// Insert Zzz after last word if you can...
const lastWord = document.querySelector('.words .word:last-of-type')
lastWord.innerHTML = `${lastWord.innerHTML}<span class="zzz"><span class="z" style="--i:0;">Z</span><span class="z" style="--i:1;">Z</span><span class="z" style="--i:2;">Z</span></span>`
const CTRL = new Pane({
title: 'Config',
expanded: true,
})
const CONFIG = {
pixels: 80,
padding: 100,
delay: 0.25,
blur: 6,
x: 0,
y: -75,
theme: 'system',
entity: 'character',
}
CTRL.addBinding(CONFIG, 'pixels', {
min: 1,
max: 500,
step: 1,
label: 'Pixels per Character',
})
CTRL.addBinding(CONFIG, 'padding', {
min: 0,
max: 500,
step: 1,
label: 'Scroll Padding',
})
CTRL.addBinding(CONFIG, 'entity', {
options: {
Character: 'character',
Word: 'word',
},
label: 'Entity',
})
CTRL.addBinding(CONFIG, 'delay', {
min: 0,
max: 1,
step: 0.01,
label: 'Delay Multiplier',
})
CTRL.addBinding(CONFIG, 'blur', {
min: 0,
max: 50,
step: 1,
label: 'Blur (px)',
})
CTRL.addBinding(CONFIG, 'x', {
min: -250,
max: 250,
step: 1,
label: 'X (%)',
})
CTRL.addBinding(CONFIG, 'y', {
min: -250,
max: 250,
step: 1,
label: 'Y (%)',
})
CTRL.addBinding(CONFIG, 'theme', {
options: {
System: 'system',
Light: 'light',
Dark: 'dark',
},
label: 'Theme',
})
const sync = () => {
document.documentElement.dataset.theme = CONFIG.theme
document.documentElement.style.setProperty(
'--pixels-per-character',
CONFIG.pixels
)
document.documentElement.dataset.entity = CONFIG.entity
document.documentElement.style.setProperty('--delay-multiplier', CONFIG.delay)
document.documentElement.style.setProperty('--scroll-padding', CONFIG.padding)
document.documentElement.style.setProperty('--blur', CONFIG.blur)
document.documentElement.style.setProperty('--x', CONFIG.x)
document.documentElement.style.setProperty('--y', CONFIG.y)
}
const handle = (event) => {
if (
!document.startViewTransition ||
event.target.controller.view.labelElement.innerText !== 'Theme'
)
return sync()
document.startViewTransition(() => sync())
}
CTRL.on('change', handle)
sync()
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.