Загрузка видео...

Не удалось загрузить видео

На главную

Future CSS && UI Tip! ⚡️ You could use View Transitions to create those word carousel-type effects 😍 span:nth-of-type(2) { view-transition-name: swap; } ::view-transition-old(swap) { animation-name: slide-down; } ::view-transition-new(swap) { animation-name: slide-up; } How To 1. Create a paragraph split into spans 2. Set an interval in JavaScript that...

230,052 просмотров • 2 лет назад •via X (Twitter)

Комментарии: 9

Фото профиля jhey ▲🐻🎈
jhey ▲🐻🎈2 лет назад

Here's that @CodePen link! 🚀 Remember. This will only work in Chromium at the moment 🤓

Фото профиля jhey ▲🐻🎈
jhey ▲🐻🎈2 лет назад

And here's the @ChromiumDev issue that got raised from making this demo 🤙 (Fix rolling out into Chrome) Another example of why making random demos can help the <web platform/> 💯 Make things. Raise bugs. Share stuff! 🤓

Фото профиля Terry
Terry2 лет назад

Safari be like

Фото профиля Matt
Matt2 лет назад

Just made exactly this, this afternoon 🔥

Фото профиля Abd Mcs
Abd Mcs2 лет назад

This is nice. I used to do this in js. I’m always inclined to css solution before get to javascript. Bookmarked

Фото профиля Luke Haines
Luke Haines2 лет назад

It doesn't render properly on my version of Chrome. When it slides in, all of the words are too small, and then after a delay they size back up to the correct height!

Фото профиля jhey ▲🐻🎈
jhey ▲🐻🎈2 лет назад

Yep – I'm not sure it's quite rolled out to everyone on Chrome yet. It should work as expected in Canary. Look out for that Chrome update 🤙

Фото профиля Ronak Bokaria
Ronak Bokaria2 лет назад

amazing 👏

Фото профиля Mainro Code
Mainro Code2 лет назад

@SaveToNotion

Похожие видео

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 просмотров • 2 лет назад