CodePen Home Web Gears ⚙️ (Scroll-driven animations)
by vovkasolovev
HTML
<nav>
<a 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>
</nav>
<div class="gears">
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 146 146">
<path fill-rule="evenodd" clip-rule="evenodd" d="m0 68 13.306-1.094a59.756 59.756 0 0 1 2.202-11.126L3.643 49.683l3.827-9.238 12.705 4.079a60.097 60.097 0 0 1 6.308-9.424l-8.637-10.183 7.07-7.071 10.185 8.637a60.15 60.15 0 0 1 7.65-5.311L38.597 8.236l9.239-3.827 6.018 11.71a59.682 59.682 0 0 1 13.052-2.813L68 0h10l1.094 13.306a59.683 59.683 0 0 1 13.052 2.813l6.018-11.71 9.239 3.827-4.154 12.936a59.613 59.613 0 0 1 3.728 2.368 60.13 60.13 0 0 1 3.922 2.943l10.184-8.637 7.071 7.07-8.637 10.185a60.086 60.086 0 0 1 6.308...
CSS
@import "normalize.css";
@font-face {
font-family: 'Geist Sans';
src: url('https://assets.codepen.io/605876/GeistVF.ttf') format('truetype');
}
*,
*:after,
*:before {
box-sizing: border-box;
}
:root {
--gutter-size: 120px;
}
body {
min-height: 100vh;
font-family: "Geist Sans", "SF Pro Text", "SF Pro Icons", "AOS Icons", "Helvetica Neue", Helvetica, Arial, sans-serif, system-ui;
padding-inline: var(--gutter-size);
font-weight: 80;
color: hsl(0 0% 10%);
}
body::after {
content: "";
width: var(--gutter-size);
position: fixed;
top: 0;
bottom: 0;
right: 0;
background: hsl(0 0% 80%);
}
body::before {
--color: white;
--size: calc(var(--gutter-size) / 6);
content: "";
width: var(--size);
position: fixed;
top: 0;
left: calc(100% - var(--gutter-size));
background:
linear-gradient(var(--color), var(--color)) 0 0 / calc(var(--size) / 2) var(--size) no-repeat repeat,
linear-gradient(-10deg, transparent 80%, var(--color) 81%) 0 0 / calc(var(--size) * 0.8) var(--size) no-repeat repeat,
linear-gradient(10deg, var(--color) 20%, transparent 21%) 0 0 / calc(var(--size) * 0.8) var(--size) no-repeat repeat;
filter: drop-shadow(0 0 6px hsl(0 0% 50%));
clip-path: inset(0 -200% 0 0);
height: calc(100vh + (var(--size) * 20));
z-index: 2;
animation: belt both linear;
animation-timeline: scroll();
}
@keyframes belt {
to { translate: 0 calc(var(--size)* -20); }
}
header {
height: 100vh;
display: grid;
place-items: center;
}
section {
height: 100vh;
width: 100%;
display: grid;
place-items: center;
}
h2 {
font-size: clamp(2rem, 1vw + 1rem, 6rem);
font-weight: 80;
}
main {
width: 80ch;
max-width: 100%;
margin: 0 auto;
padding: 0 1rem;
}
.gears {
color: hsl(0 0% 40%);
position: fixed;
top: 0;
right: 0;
width: var(--gutter-size);
z-index: 2;
filter: drop-shadow(0 1px 2px hsl(0 0% 50%));
}
.gears svg {
animation: work both linear;
animation-timeline: scroll();
}
@keyframes work {
0% { rotate: var(--start, 0deg); }
100% {...