No video

Create an infinite horizontal scroll animation

  Рет қаралды 190,737

Kevin Powell

Kevin Powell

Күн бұрын

🎓 Did you know I have courses? Both free and premium ones: kevinpowell.co/courses?...
Infinite scroll animations for things like logos are relatively common these days, but there is a lot that we can do incorrectly when making one, so I decided to try and make one that respects prefers-reduced-motion, and is progressively enhanced with just a couple of lines of JS to add in the functionality (and duplicate content that we’ll need).
🔗 Links
✅ The code from this video: codepen.io/kevinpowell/pen/Ba...
✅ My playlist on CSS masks: • CSS Masks
⌚ Timestamps
00:00 - Introduction
01:16 - The HTML
02:23 - Basic CSS
05:31 - Checking for prefers-reduced-motion with JavaScript
08:50 - Setting the stage for the animation with CSS
13:16 - Adding the animation
19:53 - Fixing the doubled content in the HTML
25:50 - Adding speed and direction options
#css
--
Come hang out with other dev's in my Discord Community
💬 / discord
Keep up to date with everything I'm up to
✉ www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 / kevinpowellcss
---
Help support my channel
👨‍🎓 Get a course: www.kevinpowell.co/courses
👕 Buy a shirt: teespring.com/stores/making-t...
💖 Support me on Patreon: / kevinpowell
---
My editor: VS Code - code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my KZfaq channel, make sure to follow me on Instagram and Twitter.
Twitter: / kevinjpowell
Codepen: codepen.io/kevinpowell/
Github: github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Пікірлер: 280
@Aliena92
@Aliena92 4 ай бұрын
"I help people fall deeply, madly in in love with css." You're succeeding every time! Thank you for all these gems!
@MarshallSC1
@MarshallSC1 10 ай бұрын
I know You don't do a lot of JS video, but man, when you do, they are beyond awesome. Thank You for the free knowledge!
@Shaheer-xs5os
@Shaheer-xs5os 10 ай бұрын
80% of my CSS skills, I have learned from you Kevin, you're the best buddy, thank you for these amzing videos ☺
@user-tc5do1ps9p
@user-tc5do1ps9p 3 ай бұрын
Same
@Catalyph
@Catalyph 3 ай бұрын
LOL 80% of my CSS skills i have learn from THIS video!😂
@e11world
@e11world 7 ай бұрын
I love the way you setup things and how you explain it so well even in JS. Thank you for these videos as always!
@lucacarrara00
@lucacarrara00 10 ай бұрын
I was just looking for this kind of animation yesterday, found few solutions but neither of them with an explanation. Now I got the idea behind it and also the reason why my infinite scroll had this kind of "jump" between the first set of icons and the second. Thanks a lot!
@kerrykreiter445
@kerrykreiter445 10 ай бұрын
Probably my favorite of all your videos I’ve seen. Thank you for sharing this incredibly useful content!! Kevin, you’re the best!
@rtindevelops7580
@rtindevelops7580 Ай бұрын
Kevin, you make me fall in love with CSS each time, I visit one of your videos . thank you so much for the value! 🙌
@yaseen2002
@yaseen2002 10 ай бұрын
Hey Kevin you are a star. This logo animation was exactly what I needed for my current project. I didn't know where to begin until I saw your KZfaq video. Thank you one more.
@naveenvenkateshk
@naveenvenkateshk 10 ай бұрын
Thank you Kevin for this informative video. 2 years ago I had a requirement to implement an infinite scroll component to display brand logos. I searched in internet and youtube but never found a proper guide / implementation. If I had this video 2 years ago, it would have saved me a ton of efforts, time and stress.
@anchimayen
@anchimayen 10 ай бұрын
Couldn't be a more perfect timing for me. I've been thinking about adding such a slider to my art portfolio website. Appreciate your work man! ✨
@webrevolution.
@webrevolution. 10 ай бұрын
Man? How dare you assume his gender?!!?!?! Lmao. Just kidding. Totally agree.
@Sunny-Gupta1
@Sunny-Gupta1 10 ай бұрын
​@@webrevolution. I am making a meme video on America'a gender crisis. I got shocked when I saw multiple gender options on Netflix's software Engineer job application lol
@Manas-co8wl
@Manas-co8wl 8 ай бұрын
Literally same
@zabuzagaming5741
@zabuzagaming5741 7 ай бұрын
You are not the only one Same here😂
@rheumaticharm9551
@rheumaticharm9551 Ай бұрын
Sir following you since the beginning of my coding journey. I'm not primarily a front end dev so your tutorials are a gem. Thanks for amazing content.
@plastikbeau3695
@plastikbeau3695 10 ай бұрын
The reason you can manipulate properties and attributes of elements created with JS is that a DOM element is just an object in JS, the difference is it does not have a context (like a parent element, etc.) before it's added to a document. Everything else is there as soon as it's created. You can even add event handlers and trigger events on it!
@lucasferrero123
@lucasferrero123 7 ай бұрын
Thanks Kevin, you've explained really well the concepts behind this animation.
@underroad
@underroad 10 ай бұрын
@KevinPowell this is great demo! I added this code to pause the animation on hover. .scroller[data-animated="true"] .scroller__inner:hover { animation-play-state: paused; }
@Thekidisalright
@Thekidisalright 10 ай бұрын
This is really wonderful so user don’t have to “chase” the button on screen, especially if the animation is any faster than what Kevin showed in the video.
@gbrl8633
@gbrl8633 5 ай бұрын
good job!
@GuebreAdama
@GuebreAdama 3 ай бұрын
Great Job, I tried it and it's working fine.
@jbink6612
@jbink6612 18 күн бұрын
man i'm struggling with my current project to get a fluid continuous effect... you made my day ... cheers from France
@memoryleakerz
@memoryleakerz 10 ай бұрын
Always on point, professional explainations, great takes, great work!
@oscarh4066
@oscarh4066 9 ай бұрын
You're the best, Kevin! Thanks for the detailed tutorial.
@tomcat1112k
@tomcat1112k 6 ай бұрын
thanks for this amazing video Kevin. Loved how thorough the lesson was. I'm gonna customize and implement your technique in my University's final project.
@chriscarton4728
@chriscarton4728 6 ай бұрын
Everytime I have a problem I realize you already had the same problem and overcame it. Thank you for lighting the way.
@royhyde8842
@royhyde8842 10 ай бұрын
As always, thanks for the great content Kevin.
@goranspasic4977
@goranspasic4977 2 ай бұрын
Ok, this is the best video so far in this area! Thank you so much!!!
@jupa8712
@jupa8712 10 ай бұрын
Hey man the tutorial was awesome. Thanks for share your knowledge 🎉
@ChecoM83
@ChecoM83 6 ай бұрын
It worked perfectly for me! Awesome tutorial! Thanks a lot.
@integrateur
@integrateur 10 ай бұрын
I had to built this last week and had a hard time, wished I had found your video before haha Merci Kevin!
@_duongductrong
@_duongductrong 6 ай бұрын
Wow, that's so amazing, I think it was so complex, but after I saw your video, understood it so easy (sorry for my English)
@dmytro_bhn
@dmytro_bhn 9 ай бұрын
Thank you my friend. Very useful and gives the site more interactivity.
@spatialoptic
@spatialoptic 5 ай бұрын
As always, THANK YOU Kevin!!!
@codetheworld6721
@codetheworld6721 5 ай бұрын
Thankyou my CSS master, you are the most helpful guy in youtube.
@bw-dude
@bw-dude 10 ай бұрын
Hey Kevin, once again great script, thank you! The moment I saw this idea I thought, "why stop with left and right?". I just played around with it, basically I duplicated the "scroll" animation, renamed it to "scrollv" and changed translate to translateY A CSS query to set the list elements to block when direction is up or down, a little CSS manicure and it works already! Currently I still have a small timing problem to fix, but I am so happy about this solution already. You just are the man!
@ROC4Life96
@ROC4Life96 Ай бұрын
Well done, great explanation
@ELStalky
@ELStalky 10 ай бұрын
The object returned from matchMedia has a "change" event, by the way. Using that, one can react to changing user (and emulation) settings without reloading the page.
@WebDeveloper682
@WebDeveloper682 10 ай бұрын
now i see , you are leveling up your animation skills
@LarryMarkel
@LarryMarkel 4 ай бұрын
You are the goat, great lesson, really informative and upbeat!
@MrAbbo11
@MrAbbo11 3 ай бұрын
Thanks so much for this, Kevin!
@lguarinosud
@lguarinosud 17 күн бұрын
Great Job!! Not even chatGPT could give me the solution for the empty gap between the duplicated items. I love you :)
@mazboost
@mazboost 8 ай бұрын
Thanks mate, well done! I just re-created it in nextJS using your code
@HuynhLuong227
@HuynhLuong227 10 ай бұрын
wow, amazing effect scroll list item, thanks for sharing
@ThePetekal13
@ThePetekal13 10 ай бұрын
I love your videos so much!
@aigeek1991
@aigeek1991 10 ай бұрын
this is pretty much exactly what I needed for a project I'm working on, now to just stop procrastinating and actually get to coding
@mr.rayparis
@mr.rayparis Ай бұрын
okay now working, thankyou kev
@anirudhk6109
@anirudhk6109 10 ай бұрын
This is so lovely. it's like magic!!
@ahooton
@ahooton 8 ай бұрын
Kevin, I've used clamp() for the column-gap value which allows me to have the scroller span any viewport width whilst keeping the column-gap responsive. I then added clamp() - with the halved values - to the calc() function. Works great! I was initially having a nightmare getting this effect to work properly until I came across your tutorial. Your solution using calc() with the translate and gap value to correct the animation glitch is brilliant. Thank you!
@TurpoChargedGaming
@TurpoChargedGaming 7 ай бұрын
Do you have a codepen with your coded version? Would be great to see how you did that! :)
@sarahtoby473
@sarahtoby473 10 ай бұрын
Thank you! I have looking for this feature 😊
@nickbrown6754
@nickbrown6754 10 ай бұрын
I have literally just struggled to build exactly this in a project. Now im going to have to go refactor it because your solution is so much cleaner and simple to what I did 😂
@umidjonzoxidov
@umidjonzoxidov 2 ай бұрын
Thank you Kevin!
@mohammedminoddinsharker8460
@mohammedminoddinsharker8460 10 ай бұрын
Hei Kevin, You are not only boss of CSS but also boss of JS. Best wishes.
@mateusmattossabarreto2852
@mateusmattossabarreto2852 6 ай бұрын
I have been trying to do something like this for about a week now. Tried to use a queue for duplicating the items, tried all kinds of weird animations and nothing worked, you really saved me
@jackwalsh6487
@jackwalsh6487 10 ай бұрын
Thanks for this tutorial Kevin! Now I have to go and change three logo scrollers on my current project because they all use duplicated content as a solution. It should help page load speed too.
@MM-um1sq
@MM-um1sq 5 ай бұрын
awesome kevin, good job 👏 I'm currently working on a svelte project and need this option the the website i did it. with typescript , svelte , tailwind, skeleton + css. i really enjoyed! ❤
@VidarrKerr
@VidarrKerr 10 ай бұрын
I am an architect, but I love CSS too. Your Videos are Awesome! Thank You!
@antonioruiz6012
@antonioruiz6012 6 ай бұрын
Same here! Cheers for us rare species 🎉
@Labastidaa
@Labastidaa 8 ай бұрын
Great tutorial Kevin, I followed this to create a React component and tailwind styles
@paulab9310
@paulab9310 6 ай бұрын
Hey @Labastidaa, I did the same thing! I am using this ininite scroll in my current React project, I decided to go with a separate CSS file for the component I have the scroller on. My only issue is is that the animation seems to work for me only when I hit save on my .js file. If I refresh the page then it all breaks and it does not look that pretty. Should I be adding some sort of hook for it? How did you get that .js file to mont every time you refresh the browser?
@fabioborba2268
@fabioborba2268 6 ай бұрын
You really helped me, thanks a lot
@isabelphillips451
@isabelphillips451 3 ай бұрын
Mhuaaa 😘😘😘😘😘 ... Heaven-sent implementation
@CirTap
@CirTap 10 ай бұрын
you might also add the standardised `dir` attribute for RTL/LTR content flow to keep the internal order of things and the right to left animation. You then use that attribute for your CSS selector.
@mundoextrano8892
@mundoextrano8892 10 ай бұрын
Thank you so much, it´s amazing
@ridewithme9422
@ridewithme9422 6 ай бұрын
Just amazing, jussssttttt Amazing. As a beginner who want to start in industry , I hope I get a senior like you. Respect 🚀🚀
@ousssika5359
@ousssika5359 2 ай бұрын
thanks man , thanks mush love
@yeasinarafat540
@yeasinarafat540 10 ай бұрын
thank you so much for the knowledge
@skillzorskillsson8228
@skillzorskillsson8228 10 ай бұрын
you probably already know this, but you can shorten the gradient in the mask by using -webkit-mask: linear-gradient(90deg, transparent, white 20% 80%, transparent); so you don't need to write "white" twice
@KevinPowell
@KevinPowell 10 ай бұрын
One of those things I know when I see it, but never remember that we can do when I need to do it myself 😅
@skillzorskillsson8228
@skillzorskillsson8228 10 ай бұрын
@@KevinPowell 😂😅
@soype
@soype 10 ай бұрын
I hate scrolling sliders because whenever I have to create a new one I forget what I did before. Adding this to my playlist!
@nomad100hd
@nomad100hd 10 ай бұрын
If you track the parent's width and the width of the children and put the `forEach` that adds items into a `while` loop, you can continue adding them until there are enough items to eliminate any gaps, regardless of the size and number of child elements.
@roy.mancini
@roy.mancini 4 ай бұрын
can you share the code you mean? I have a problem when the items are not enough to fill the container. I want to duplicate the items before finish the first cicle.
@hannanurrahman1701
@hannanurrahman1701 7 күн бұрын
great sir😇 it was awesome
@amaizingcode
@amaizingcode 9 ай бұрын
Wonderful! Thanks!
@cspjdbh
@cspjdbh 10 ай бұрын
Perfect video!
@John-King87
@John-King87 10 ай бұрын
Another masterpiece ❤❤
@gbrl8633
@gbrl8633 5 ай бұрын
an incredible class
@harryprowess9871
@harryprowess9871 9 ай бұрын
Respect man 🙌
@JordanAF808
@JordanAF808 8 күн бұрын
Every video I'm always like, I wish I knew about this 2 days ago 🤣
@sai_charan
@sai_charan 10 ай бұрын
Thanks Kevin!
@hameeeed5992
@hameeeed5992 3 ай бұрын
rather than adding the list individually within ul , u can create a variable with the list items and a function that concatenates a list with itself. Now within the ul tag, u can map through the concatenated list items (using the function so it doubles), and create a list tag for each.
@leehoss
@leehoss 10 ай бұрын
Nice video - would be good to show in vertical scrolling as well - I assume it would work the same way. Additionally be good if the scroll speed could work of the inner scroll width so you could get consistent speed regardless of content size :)
@hassaneoutouaya
@hassaneoutouaya 10 ай бұрын
Thank you so much!
@khanhduy3364
@khanhduy3364 7 ай бұрын
amazing video
@SaadAlShiekhAli-sg4dl
@SaadAlShiekhAli-sg4dl 5 ай бұрын
bro you are the king, thankssssssssssss
@gr81matt
@gr81matt 10 ай бұрын
This one was very cool.
@user-jz4iz2qh9u
@user-jz4iz2qh9u 10 ай бұрын
Awesome video! Could be nice making that as a webcomponent.
@cwilcox808
@cwilcox808 10 ай бұрын
So good, seeing the animation depend on "Reduce motion" not being enabled. And good to see `aria-hidden="true" `being added to the duplicated items, so a screen reader user wouldn't have to navigate through them. But what if the images were wrapped in links? The links would still be in the focus order so a keyboard user would still have to navigate through them all. At first I thought the solution would be to use the `inert` attribute instead of `aria-hidden`, making them both hidden from screen readers and non-interactive. However, that would prevent cursor/touch users from clicking on the duplicated links; awkward. The solution is to do what was done before `inert` was supported, add `tabindex="-1"` to the duplicated links. As long as we're thinking about keyboard users, how awkward is it to be focusing on links that are animating? That can be addressed by adding a couple of `:focus-within` rules, one to change the `overflow` from `hidden` to `scroll` and another for the `animation` property so it only animates when `:not(:focus-within)`.
@KevinPowell
@KevinPowell 10 ай бұрын
I don't think I'd ever use something like this for content I expect the user to interact with. Carousels where the user has control are problematic enough, something like this that scrolls by sounds like a nightmare from a UX perspective, even for fully abled users using a mouse. That said, I love that you thought about it and came up with some valid solutions to make it work, because you just know a client is going to ask for that 😅
@crstnio
@crstnio 10 ай бұрын
Hey, I learned something today. 👍
@beinyourguard
@beinyourguard 8 ай бұрын
pretty neat!
@pmakosyo
@pmakosyo 10 ай бұрын
man, you save me. Every time i was creating a marquee i have the issue with the sudden cut of the rotation.
@LuBre
@LuBre 10 ай бұрын
A _responsive_ version with no max-width would be ace!
@rain-2263
@rain-2263 10 ай бұрын
That's what I about to ask for ❤
@jessnobotak6038
@jessnobotak6038 26 күн бұрын
thank you , you are good person yes. with this i hope ill actually get a job now
@ivanvasquez2023
@ivanvasquez2023 4 ай бұрын
esta bueno el contenido, lo he adaptado para Angular y que cubra el 100% del espacio del contenedor, gracias
@user-ij9dy7vp9y
@user-ij9dy7vp9y 10 ай бұрын
beautiful thing godfather, thanks thanks 👍
@melvinace5
@melvinace5 10 ай бұрын
Awesome!! 🤩🤩🤩. Can you do another version, like with previous and next button? Thanks man!
@mafhper
@mafhper 10 ай бұрын
About ten years ago, a client asked for a website made in sections that had a side scroll. As much as I tried to convince them otherwise, I had to. It was a cool challenge. I used parallax in some parts. Usability 0, style 10.
@santoshparker8681
@santoshparker8681 10 ай бұрын
Lovely 😍
@jerondiovis6128
@jerondiovis6128 9 ай бұрын
To improve JS part a bit, you could add all duplicate nodes to DOM in one go - by first creating a Fragment, appending nodes to it, and then appending fragment to scrollContent. Only one DOM modification instead of many, would save some milliseconds on initialization of this scroller.
@TurpoChargedGaming
@TurpoChargedGaming 7 ай бұрын
Trying to learn more JS. Do you have a codepen or link to an example of this? Would be great to see! :)
@bikinglikebecker
@bikinglikebecker 10 ай бұрын
awesome sauce
@growwithdesign
@growwithdesign 6 ай бұрын
Much appreciated. Just an idea suggestion - can you create this in React Next JS with Typescript and Tailwind CSS?
@normanejm
@normanejm 10 ай бұрын
Thank you!!!
@gabrielomane-yeboah
@gabrielomane-yeboah 8 ай бұрын
The GOD of CSS🚀
@Karen-fy7mq
@Karen-fy7mq 3 ай бұрын
Muchas graciasssss!!!!!!!!!!!!
@hassan2868-u7q
@hassan2868-u7q 10 ай бұрын
this is perfect, but I wanna try it by taking the first child remove it and then put it at the end. idk how performant it will be against this tho
@dadoual2956
@dadoual2956 2 ай бұрын
How can i adjust that to us it in a vertical way ? thanks so much for ur works!
@whereIsJerome
@whereIsJerome 9 ай бұрын
for mac users who like to fiddle with their system settings, make sure accessibility > display > reduce motion is turned off!
@ItsMeShadowz
@ItsMeShadowz 10 ай бұрын
Why have I never heard of the mask property? Definitely stealing this mask implementation for some components I have.
@Qbikowski
@Qbikowski 3 ай бұрын
hey, it works great, is there any way to add option that we can scroll also scroll manually with mouse/touch?
@colesniucalex8703
@colesniucalex8703 Ай бұрын
how do you activate the option to see what you code
This is the hardest CSS Battle I've tried
1:27:43
Kevin Powell
Рет қаралды 109 М.
Can I copy this cool effect with CSS?
37:06
Kevin Powell
Рет қаралды 175 М.
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Chapitosiki
Рет қаралды 7 МЛН
Box jumping challenge, who stepped on the trap? #FunnyFamily #PartyGames
00:31
Family Games Media
Рет қаралды 25 МЛН
Son ❤️ #shorts by Leisi Show
00:41
Leisi Show
Рет қаралды 9 МЛН
Creating an infinite logo carousel with pure CSS
12:18
Coding with Robby
Рет қаралды 125 М.
Learn CSS Grid the easy way
37:04
Kevin Powell
Рет қаралды 892 М.
You Don't Need JavaScript For This - CSS ONLY Infinite Scroll
23:35
Slaying The Dragon
Рет қаралды 87 М.
Relative colors make so many things easier!
13:16
Kevin Powell
Рет қаралды 46 М.
Responsive layout practice for beginners
1:11:37
Kevin Powell
Рет қаралды 103 М.
Incredible scroll-based animations with CSS-only
32:23
Kevin Powell
Рет қаралды 404 М.
Create direction-aware effects using modern CSS
18:30
Kevin Powell
Рет қаралды 65 М.
Use these instead of vh
6:06
Kevin Powell
Рет қаралды 496 М.
Subgrid & Container Queries change how we can create layouts
21:08
Kevin Powell
Рет қаралды 74 М.
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Chapitosiki
Рет қаралды 7 МЛН