Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

CSS scroll-driven "CTA to Nav" 🗺️ nav { grid-template-columns: auto calc(var(--grow) * 240px) auto; transition: 1s var(--custom); } @​keyframes expand { to { --expand: 1; } } body { animation: expand steps(1); animation-timeline: --hero; animation-range: exit; }

263,187 Aufrufe • vor 2 Jahren •via X (Twitter)

11 Kommentare

Profilbild von Marc Grabanski
Marc Grabanskivor 2 Jahren

Hope you make tons of $ off the book. You know I’m buying it!

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 2 Jahren

If it ever materializes 😅 Maybe I should do a Kickstarter haha. Saw someone doing that for a component library the other day!

Profilbild von yaf
yafvor 2 Jahren

i need to create a bookmark folder just for your post man

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 2 Jahren

@pengenradiant Will be easier when I finally make a website for them all

Profilbild von Xi
Xivor 2 Jahren

damn. damn what's the limit... i need to get these bookmarks in a folder. brilliant

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 2 Jahren

I need to make a site for them 🧑‍🍳

Profilbild von Israel 🤖
Israel 🤖vor 2 Jahren

@aneriemmanuel 🤲.. for the landing page cta to nav

Profilbild von Atif Riaz
Atif Riazvor 2 Jahren

Done beautifully 😍

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 2 Jahren

Thanks Atif 🤙

Profilbild von Kristopher Fana
Kristopher Fanavor 2 Jahren

Man you’re a hero!

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 2 Jahren

🤙

Ähnliche Videos

CSS Tip! 🍬 You can create a CSS-only sticky CTA using position: sticky or scroll-driven animations 🤙 .cta { position: sticky; margin-top: 110vh; bottom: 2rem; /* 👈 Stick! */ } This is one way 👀 This first way relies on you setting a layout on the body and putting the CTA in a zero-space part of the layout body { display: grid; grid-template-columns: auto 0; } The children of the body are an element with your content and then the CTA. You could also use display:flex too. .content { flex: 1 0 100%; } .cta { place-self: end; } As you scroll the body, the CTA comes into view and sticks in position 🙌 That's one way. If you want to take it further and do something like flip between showing or not, maybe scale it up, or add some special easing, etc. an animation is another way 📜 First, change the styles for your CTA. Note the translate property that's powered by a custom property .cta { position: fixed; bottom: 2rem; right: 2rem; translate: 0 calc(20vh - (var(--show) * 20vh)); transition: translate 0.875s var(--elastic); } Next you need a custom property that you're going to animate @​property --show { inherits: true; initial-value: 0; syntax: ' '; } Lastly, you animate this value on the body. As the property value changes, the value will trickle down to the CTA @​supports (animation-timeline: scroll()) { body { animation: show-cta both steps(1); animation-timeline: scroll(root); animation-range: 0 10vh; } @​keyframes show-cta { to { --show: 1; } } } Using @​supports you can use this as a progressive enhancement. If scroll-driven animations are supported, use them. Otherwise fallback to using position: sticky 🤙 That's it! As always, any questions or requests, hit me up! 🙏 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

133,003 Aufrufe • vor 2 Jahren

CSS Tip! 📜 You can use scroll-driven animations to progressively enhance collapsing a floating call to action 🤏 .cta { animation: shrink; animation-timeline: scroll(); animation-range: 0 100px; } @​keyframes shrink { to { width: 48px; } } That's the gist of it. Use the body scroll position with animation-timeline: scroll(). Define the animation-range as when you have scrolled 100px. There's a little more though 🤓 That would "scrub" the width animation. Ideally, you want to trigger that animation. You could animate a custom property with steps() timing and use that to define the width ✨ @​property --scrub { syntax: ' '; inherits: true; initial-value: 0; } body { animation: scrub both steps(1, end); animation-timeline: scroll(); animation-range: 0 100px; } Then transition the --scrub property on the CTA and use it for the width 🤙 .cta { transition: --scrub 0.2s; width: calc(48px + (120px * (1 - (var(--scrub) / 100)))); } Other animations are a matter of preference and timing. For example, you could then make the hand wave, scale down the size, and then slide a gradient across 😉 They have the same structure and technique as the original concept. Waving the hand? 👋 Run it twice, offset the transform-origin. .hand { animation: wave both linear 2; animation-timeline: scroll(); animation-range: 30vh 50vh; transform-origin: 65% 75%; } @​keyframes wave { 50% { rotate: 20deg; } } How's it progressively enhanced? Wrap everything in a @​supports query and a @​media query. If there isn't support, users still get a good experience. It's a floating action button that's circular and already collapsed 🤙 @​supports(animation-timeline: scroll()) { @​media(prefers-reduced-motion: no-preference) {...} } Definitely have a play with the code. Amazing what we're going to be able to do with CSS alone! 🔥 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

177,781 Aufrufe • vor 2 Jahren