Animate On Scroll With Just 3 LINES Of CSS (No Libraries Needed)

Sdílet
Vložit
  • čas přidán 31. 05. 2024
  • Hi everyone, Snippets Code here
    Focus of today’s video is to create this effect, where the elements are being smoothly animated when the page is being scrolled, and various animations are also being applied. All this with 3 simple lines of css.
    🔔 Subscribe now
    To stay updated on our upcoming design tutorials. Don't forget to hit that notification bell so you never miss a valuable lesson.
    Link to code: github.com/SnippetsDevelop/sn...
    For Business 💼:
    snippetsdevelop@gmail.com
    #htmlcsswebsitedesigntutorial #htmlcsswebsite #htmlcsswebsitedesign #htmlcsswebsitetutorial #htmlcsswebsiteproject #htmlcsswebsiteportfolio #htmlcsswebsitelayout #htmlcsswebsiteresponsive #htmlcsswebsitedesigntutorialvisualstudiocode #htmlcsswebsiteforbeginners #animateonscroll #animation #jsanimation

Komentáře • 144

  • @Snippets_Code
    @Snippets_Code  Před 26 dny +8

    If you find this video valuable then do Like Share Comment and Subscribe to the channel: czcams.com/channels/NWGZXzuU9oGggS2egZiKxA.html

  • @lazyjoe597
    @lazyjoe597 Před 19 dny +28

    So now let's wait another 5 years or so for Apple and Mozilla to implement it into their browsers so we can finally use this feature. Until then good old JS is the only way

  • @maestrogoldring1094
    @maestrogoldring1094 Před 24 dny +16

    Randomly suggested to me from CZcams. It was a good suggestion. Simple and short explanation, just how I like 👍

  • @AestheticalMinimalism
    @AestheticalMinimalism Před 10 dny +3

    No JS? You're a bloody genius!

  • @nicolasmayorga8288
    @nicolasmayorga8288 Před 24 dny +8

    00:00 here and trying to sleep and just found this wonder, thanks for this content and the way you explained was amazing. I really appreciate it ❤

  • @Fluff-9
    @Fluff-9 Před 22 dny +2

    You are amazing. I have been searching the Internet for so long. This video answered all my questions. Thank you.

  • @towercontrol4450
    @towercontrol4450 Před 15 dny +8

    The only problem with this aproach is browser support, for animatio-timeline and animation-range is still low

  • @aryanisgood
    @aryanisgood Před 26 dny +2

    I was just making a cafewebsite project and came across this. Gonna use it for the project. Thanks

  • @Iskael
    @Iskael Před 26 dny +18

    can not run in Safari and Firefox

    • @Snippets_Code
      @Snippets_Code  Před 25 dny +8

      Yes, It is a new feature of CSS, so has limited availability. Maybe later those browsers will also become compatible

    • @aldyreal
      @aldyreal Před 25 dny +8

      You should notice this in the video btw

  • @xViiiZe
    @xViiiZe Před 26 dny +3

    One of my favourite channels!!!!!!!!!!

  • @jaromanda
    @jaromanda Před 18 dny +12

    Chrome experimental features should not be used in production

  • @faizbyp
    @faizbyp Před 23 dny

    thank you very much! this is exactly what I need

  • @MuhammadShoaibOfficial
    @MuhammadShoaibOfficial Před 19 dny +6

    Safari and Firefox, both desktop and mobile versions, are not supported.

  • @SmartC2007
    @SmartC2007 Před 21 dnem +2

    Very nice and very well explained. Thank you very much.

  • @minolruckshan5396
    @minolruckshan5396 Před 21 dnem +1

    This worked perfectly on project....!!! nice...❤

  • @boomba118
    @boomba118 Před 8 dny +1

    i like this approach, straight to the point short video, no bs talking no what is animation no hello welcome to my channel bla bla... awesome :D thank u for great tip

  • @muhammad_zohaib936
    @muhammad_zohaib936 Před 22 dny +1

    Thanks a lot I needed that kinda explanation appreciated🙏❤

  • @victoriamarchi6973
    @victoriamarchi6973 Před 24 dny +1

    Excellent video!! Quite concise and straight to the point :) thank you!! new sub!!

  • @Atul_Thakre30
    @Atul_Thakre30 Před 26 dny +1

    Thank you so much for this 🔥🔥

  • @MarcosDemian
    @MarcosDemian Před 11 dny

    Awesome tutorial and to the point. Liked and subscribed

  • @edsHTML
    @edsHTML Před 12 dny +1

    i didnt know this. I now learned these css properties 😀😀

  • @user-uc5kl1dw7i
    @user-uc5kl1dw7i Před 3 dny

    So cool and easy!

  • @solongdygaming4729
    @solongdygaming4729 Před 19 dny +2

    Thanks you ❤

  • @RuTe-tr3bj
    @RuTe-tr3bj Před 26 dny +2

    Awesome trick 👏👏

  • @valentynsjoyjitsu
    @valentynsjoyjitsu Před 4 dny

    Nice idea 👌 thank you 🙏

  • @thewebstylist
    @thewebstylist Před 22 dny +1

    Amazing!

  • @cwirus99
    @cwirus99 Před 21 dnem +7

    In video like this, where cutting edge CSS features are used, you really should mention the browser support, which at this point is not great for on-scroll animations - only Chromium has already implemented it.

    • @Snippets_Code
      @Snippets_Code  Před 21 dnem

      Sure I will try to mention that in future videos 🙂

    • @qewela
      @qewela Před 21 dnem

      ONLY CHROMIUM? bro almost every browser is built on chromium. but u got a point

    • @vosyasabesquien
      @vosyasabesquien Před 21 dnem

      @@qewela maybe on desktop. on ios safari does not work

    • @cwirus99
      @cwirus99 Před 20 dny

      ​@@qewela true, but still. Depending on your target market, chromium based browsers usage can be as little as 50%.

  • @RajThakur-ol8mg
    @RajThakur-ol8mg Před 8 dny

    I liked it. I'm looking exact this video 👍💯

  • @gabrielvasconcelos2166

    Very nice video! Previously, I activated the animation using JavaScript, with an event listener or the Intersection Observer

  • @AhmedHuzain
    @AhmedHuzain Před 11 dny

    Thanks a lot!

  • @saranshparashar4257
    @saranshparashar4257 Před 23 dny +1

    Really helpful. Please create more animation videos for css which includes minimum use of js.

  • @mudyeet_
    @mudyeet_ Před 15 dny +2

    I hope you don't get bothered by the critics, I liked the video, it's 3 lines that are making the difference, if the critics wanna complain, they can try the intersection observer to implement the same thing and come back to say this is verbose or clickbait.

  • @user-jr8zv1oz6d
    @user-jr8zv1oz6d Před 25 dny +1

    merci frr c tres utileee

  • @victorcano6066
    @victorcano6066 Před 15 dny +2

    nice video bro! 🫶

  • @uifry
    @uifry Před 22 dny +1

    Amazing :)

  • @alexcostal3749
    @alexcostal3749 Před 22 dny +1

    Amazing

  • @merlinmeraldz
    @merlinmeraldz Před 4 dny +1

    nice tip, hopefully firefox and safari support comes fast

  • @NicMulvaneys
    @NicMulvaneys Před 7 dny

    Nice! 🎉

  • @ishpeeedy
    @ishpeeedy Před 9 dny

    brilliant !

  • @mehdimansouri1547
    @mehdimansouri1547 Před 23 dny +1

    fantastic

  • @tylerpetrov8094
    @tylerpetrov8094 Před 22 dny +1

    Great video! Not sure why everyone is giving you so much trouble about the "3 lines" deal. It seems like 3 line to me, key frames don't count lol. I'll definitely try and implement this in my projects!
    God bless!

  • @mohaymenul-islam
    @mohaymenul-islam Před 22 dny +1

    awesome

  • @CristianKirk
    @CristianKirk Před 20 dny +11

    Great but beware of browser support.

  • @itsatomtech
    @itsatomtech Před 21 dnem +2

    A fairly new addition... and not standard yet...

  • @dominikrodler8010
    @dominikrodler8010 Před 24 dny +1

    sick

  • @LedaseLikdsewa
    @LedaseLikdsewa Před 12 dny

    amazing

  • @ring11037
    @ring11037 Před 19 dny +6

    '3 lines' seems like a clickbait after all. But this is cool stuff, I'm glad that I clicked. Thanks for sharing.👍

  • @kevingonzalocruzmartinez8429

    Wow thanks you bro, the video very short and direct, saludos desde México

  • @HamzaAli-rn1cc
    @HamzaAli-rn1cc Před 9 dny

    Bro is genious

  • @yonatandawit8112
    @yonatandawit8112 Před 12 dny

    Nice

  • @kellog89
    @kellog89 Před 2 dny

    Very interesting from a technical point of view. However, are animations necessary or even enjoyable from a UX point?

  • @ib4112
    @ib4112 Před 9 dny +1

    Nice way of doing it. can you also do a video on GSAP animation.

  • @saurabhp94
    @saurabhp94 Před 11 dny +2

    This is still under development, not supported yet with browser hosting deployed server

  • @DANNFIGDESIGNS
    @DANNFIGDESIGNS Před 15 dny +2

    Three lines. 🥳🎉

  • @MauroAmador
    @MauroAmador Před 17 dny +4

    Nice effect, but just compatible in chrome and edge, hope fully compatible

  • @blackpurple9163
    @blackpurple9163 Před 24 dny +4

    How's the browser support for these?

    • @Snippets_Code
      @Snippets_Code  Před 24 dny

      As these are new advanced features of CSS, chrome and edge are currently supporting these. Maybe safari and firefox might become compatible soon

    • @blackpurple9163
      @blackpurple9163 Před 24 dny

      @@Snippets_Code doubt about Firefox, I've seen it fall behind a lot compared to it's older days 😔
      I prefer FF and this frustrates me a lot

  • @satwikpanda2469
    @satwikpanda2469 Před 23 dny +1

    if there is any overflow-hidden it won't work instead change it to overflow-clip

  • @thegabeserna
    @thegabeserna Před 22 dny +5

    cool stuff but it’s not really “in only 3 lines”

    • @Tanishkmalviya
      @Tanishkmalviya Před 20 dny

      It's 3 lines
      You just don't know that fact that he used 1 line = 4 lines 😂

  • @foysalahmedmin
    @foysalahmedmin Před 21 dnem +1

    Alhamdulillah.

  • @atharva6738
    @atharva6738 Před 17 dny +2

    The best thing we can use is aos (animation on scroll)

    • @shiva_mahto
      @shiva_mahto Před 17 dny +1

      That library has not been updated, even touched in 6 years, why would you use a library when you can achieve the same result with plain css.

  • @horaciomanuliwd
    @horaciomanuliwd Před 4 dny +1

    Hello GENIUS!!! I want to thank you INFINITELY for providing your knowledge. I ALREADY SUBSCRIBED TO YOUR CZcams CHANNEL, AND I STARTED FOLLOWING YOU ON GITHUB. Greetings from Buenos Aires!!!

  • @alihamdane
    @alihamdane Před 19 dny +3

    لماذ لما تستخدم animation timelinr scroll instead of view

    • @Snippets_Code
      @Snippets_Code  Před 19 dny +1

      Scroll means the animation happens when the view port is scrolled, instead of when the elements enter view port

  • @nishantkr5759
    @nishantkr5759 Před 23 dny +1

    I was searching for this exact css for days
    You have no idea how much this video means to me 😘
    I had to subscribe
    Btw is this how react loads and unhide contents on scroll ? Or react uses something else ?

    • @Snippets_Code
      @Snippets_Code  Před 23 dny

      I think there won't be any change of effect on this with react

    • @nishantkr5759
      @nishantkr5759 Před 23 dny

      @@Snippets_Code Yeah but I'm learning react and they say react is fast because it loads only those contents the user views which makes the app faster
      So is the same as the react thing ?

    • @Snippets_Code
      @Snippets_Code  Před 23 dny

      No no, it is isn't that way, the meaning of the statement is that, it loads those components first which are being utilised and remaining can have lazy loading. Anyway once a component is loaded the css gets applied to it, so whenever the component enters the view port, this effect gets applied.

    • @nishantkr5759
      @nishantkr5759 Před 23 dny

      @@Snippets_Code 😐 but I've seen way websites where they have this scroll effect and when I incept it then shows react components..
      So if this is not the way then how do they achive this load on scroll using react ...??
      I'm sorry I might be asking out of context question but I couldn't find the answer on CZcams nor in Chat...

    • @Snippets_Code
      @Snippets_Code  Před 23 dny

      Can you share any reference site, so that I can understand, what scroll effects you mean. But at the end, it also depends on the way you use your components, modules you use and mainly on the functionality you want to achieve. 🙂

  • @AshwinSI-px5yo
    @AshwinSI-px5yo Před 18 dny +4

    Can you provide the full code both html and css

    • @Snippets_Code
      @Snippets_Code  Před 18 dny +2

      I have mentioned the link to the code in description 🙂

  • @html86
    @html86 Před 21 dnem +1

    How we can add this in react and next js project

  • @wlockuz4467
    @wlockuz4467 Před 26 dny +2

    Is it possible to do it only once? I don't want the reverse animation if I am scrolling up.

    • @Snippets_Code
      @Snippets_Code  Před 26 dny +4

      Maybe that is a little complicated, and you might need to introduce JS to detect backward scroll and pause the animation. But if I find any pure CSS solution, I will surely let you know 🙂

    • @upyrov
      @upyrov Před 24 dny

      this is most likely impossible, you need to have a state. use IntersectionObserver API

  • @YasirJabri
    @YasirJabri Před 23 dny +1

    We definitely need a css library similar to animate.css (or it's js support library wow.js) open source

  • @usernameusernameusername12

    How do i set it to make the animation dont replay again when i scroll up

    • @Snippets_Code
      @Snippets_Code  Před 23 dny +1

      Currently there isn't anything that could detect backward scroll, and stop animation, in css. You might have to introduce little javascript to detect the backward scroll and pause the animation

    • @usernameusernameusername12
      @usernameusernameusername12 Před 23 dny +1

      @@Snippets_Code oh ok, thx! Great video 🙂

  • @ScientificZoom
    @ScientificZoom Před 20 dny +2

    ✌️👌✋👌

  • @ujjwalchoudhary7219
    @ujjwalchoudhary7219 Před 15 hodinami

    Can i get the css of the all boxes how they arrange?

  • @user-kw1uw5we1e
    @user-kw1uw5we1e Před 26 dny +1

    it doesn't work with tailwindcss reat.tsx app why ?

    • @Snippets_Code
      @Snippets_Code  Před 26 dny +1

      It will work, with tailwind css, but as these are new features in CSS, just check the compatibility of the browser 🙂

    • @satwikpanda2469
      @satwikpanda2469 Před 23 dny

      I am facing the same issue
      were you able to solve it?

  • @violonist-pl4tt
    @violonist-pl4tt Před 23 dny +1

    It doesnt playfor me. idk why. My site is a complete portofilo website i wanted to add animation to.

    • @Snippets_Code
      @Snippets_Code  Před 23 dny

      These are some new advanced features in CSS, so they have limited availability, currently compatible with chrome and edge

    • @violonist-pl4tt
      @violonist-pl4tt Před 22 dny +1

      @Snippets_Code oh, actually I am using Edge.
      But it was late night when I was trying to code. I will try again tomorrow. Thanks for the easy tuttorial

  • @talhasifat15
    @talhasifat15 Před 9 dny

    Hi, Does it work next. I try doing it, and it works once, and then it's the 2nd day I am trying it but it's not working. I tried doing it with HTML/CSS only then did it work. does anyone have an idea of why it not working with Next?

    • @JaskaranSingh-le4tm
      @JaskaranSingh-le4tm Před 7 dny

      the animation-time and view both are new properties. So these have limited browser compatibility. For ex- These are not supported by FireFox and Safari.

  • @l.sureshkumar-lsk550
    @l.sureshkumar-lsk550 Před 21 dnem +1

    Share the code pls

  • @phat80
    @phat80 Před 21 dnem +7

    It’s useless as it won’t work in safari and firefox!

    • @Snippets_Code
      @Snippets_Code  Před 21 dnem +5

      Currently these features are supported in chrome and edge, might be added to safari and firefox later 🙂

    • @Param3021
      @Param3021 Před 20 dny

      It's useful if you use the right browser.

    • @JakeSavageOpinion
      @JakeSavageOpinion Před 20 dny +3

      ​@Param3021 I wish you all the best telling your users that

  • @sesil2459
    @sesil2459 Před 21 dnem +4

    Well, animation-timeline has not really good browsers support...

    • @Snippets_Code
      @Snippets_Code  Před 21 dnem

      Yeah, currently it is compatible with chrome and edge

    • @phat80
      @phat80 Před 21 dnem

      @@Snippets_Codeif it’s not supported at least by Safari you should consider it does not exist.

  • @user-ip1rx2vs6j
    @user-ip1rx2vs6j Před dnem

    Safari does not support this way of scroll-based animation

  • @BhaktiTone
    @BhaktiTone Před 17 dny +2

    Hum na to pagal hain, aur na hamara dimag kharab hai.

  • @jamworthy14
    @jamworthy14 Před 9 dny

    ME who just Started WEb development 😮😭

  • @znkdev
    @znkdev Před 23 dny +102

    3 lines? you sure you want to make this clickbait?

    • @Snippets_Code
      @Snippets_Code  Před 23 dny +8

      Nope, Not a clickbait, these are some new features in CSS which you can explore 🙂

    • @znkdev
      @znkdev Před 22 dny +41

      @@Snippets_Code I found it nice, and liked the video, but it is not in 3 lines!

    • @user-om1te4qo7k
      @user-om1te4qo7k Před 22 dny +14

      ​@@Snippets_Code well if you didn't do as thumbnail said ,it's clickbait new feature or not

    • @ktldon
      @ktldon Před 22 dny +7

      ​@@znkdevif you exclude the animation css, it is indeed 3 lines of code. Still pretty simple code anyway

    • @xDmtm
      @xDmtm Před 22 dny +27

      It's 3 lines!
      animation: ...
      animation-timeline: ...
      animation-range: ...

  • @DaMu24
    @DaMu24 Před 16 dny +9

    3 lines? more like 13 lines.
    Also doesn't work in Firefox, so nice try...

    • @Snippets_Code
      @Snippets_Code  Před 16 dny +5

      Actually I meant that you can make any type of animation happen when scrolled by including those 3 CSS lines only, and I didn't include the CSS of the blocks, text, basic body styling in video, if those were mentioned, it would have been more than 13 lines also 🙂
      Not mentioning the support for the advanced CSS feature is a mistake, I will make sure to mention that when required in future videos.

    • @diegocamacho6060
      @diegocamacho6060 Před 15 dny +1

      @@Snippets_Code 🤗🤗

  • @3litepker
    @3litepker Před 18 dny +6

    If it’s not supported on the main browsers then it’s really silly to even entertain this. Until it’s supported it’s trash and has no use in production. 99% of use cases will require all of the main web browsers

    • @Snippets_Code
      @Snippets_Code  Před 18 dny +4

      It is a new feature in CSS, supported in chrome and edge and also fun to use 🙂

  • @heartbreaker7021
    @heartbreaker7021 Před dnem +1

    diskliked for click bait

  • @knowname5354
    @knowname5354 Před dnem

    Unsupported for production app. Dislike