Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Not many lines for a CSS parallax effect either 🤙 ul { scroll-padding-inline: calc(50% - var(-card) * 0.5); } img { animation: para; animation-timeline: --item; } @​keyframes para { cover 100% { translate: calc(100% - var(--card)) -50%; }}

274,260 Aufrufe • vor 2 Jahren •via X (Twitter)

11 Kommentare

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

Love a little challenge like these when they pop up on the timeline 🤓 Of course, a few more lines are needed in total but these are the main parts of getting it working 🤙 --item is an inline view timeline on the parent li { view-timeline: --item inline; }

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

Here's the @CodePen link! 🚀 Chrome for now but I can add a little GSAP to cover if you need it 🤙 Big fan of this scroll-padding-inline trick though 🏅

Profilbild von Prince
Princevor 2 Jahren

not working, can you send full codepen link?

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

Yeah, I'll ping it in. Giving it a little update 🤙

Profilbild von Bimbi.sol ☥
Bimbi.sol ☥vor 2 Jahren

Brother your css skills are next level 🤯🤯🤯 learninng everyday with your content, huge thanks

Profilbild von Mr Bird
Mr Birdvor 2 Jahren

This is gorgeous

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

Thanks! Tonight's Sudoku 😄

Profilbild von David ▲● ◻️⁾⁾⁾
David ▲● ◻️⁾⁾⁾vor 2 Jahren

I feel like a successful YouTube channel could be doing the same UI in CSS Swift UI and Jetpack Compose UI.

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

Yeah – I need to invest some time in the YouTube channel again 💯

Profilbild von Rohit Gupta
Rohit Guptavor 2 Jahren

This one looks super cool! Not less, not too much. Thanks for sharing sir 🫡🙌

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

Thanks Rohit 🤙

Ähnliche Videos

CSS Tip! 🚥 You can create these trending expanding scroll indicators with scroll-driven animations and flex 🤙 .indicator { animation: grow; animation-range: contain calc(50% - var(--size)...; animation-timeline: var(--card); } @​keyframes grow { 50% { flex: 3; }} What's the trick? Put the indicators in a container using flex layout and set a width larger than the number of indicators 😉 .indicators { aspect-ratio: 7 / 1; display: flex; } Importantly, set no gap 🤏 To mimic the gap set a transparent border on each indicator and set the background using padding-box .indicator { background: linear-gradient(#​fff, #​fff) padding-box; border-radius: 50px; border: 4px solid transparent; } Now for the animation. You want to create a view-timeline for each card that moves across 🤙 li:nth-of-type(1) { view-timeline: --one inline; } li:nth-of-type(2) { view-timeline: --two inline; } Make sure they use the inline axis too! The trick is hoisting these view-timeline so the indicators can use them with timeline-scope 👀 .track { timeline-scope: --one, --two, ...; } All that's left is for you to create the animation piece using some calc with the card size ⚡️ .indicator { --size: calc(var(--card-width) * 0.9); animation: grow both linear; animation-range: contain calc(50% - var(--size)) contain calc(50% + var(--size)); } .indicator:nth-of-type(1) { animation-timeline: --one; } .indicator:nth-of-type(2) { animation-timeline: --two; } @​keyframes grow { 50% { flex: 3; }} And there you have it, responsive scroll indicators using CSS scroll-driven animations 😎 Sprinkle a little JavaScript to make them clickable and scroll the the right card ✨ const shift = (event) => { if (event​.target.tagName === "BUTTON") { const index = [...event.target.parentNode.children].indexOf(event​.target); const item = document.querySelector(`li:nth-of-type(${index + 1})`); item.scrollIntoView({ behavior: "smooth", inline: "center" }); } }; As always, any questions or suggestions, let me know. I've put a JavaScript fallback in to use GSAP in browsers that don't have scroll-driven animations 🫶 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

575,316 Aufrufe • vor 2 Jahren