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

Поділитися
Вставка
  • Опубліковано 1 лют 2025

КОМЕНТАРІ • 329

  • @Snippets_Code
    @Snippets_Code  8 місяців тому +22

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

    • @cool5019
      @cool5019 7 місяців тому +1

      Thanku 🎉

  • @maestrogoldring1094
    @maestrogoldring1094 8 місяців тому +17

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

  • @Fluff-9
    @Fluff-9 8 місяців тому +2

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

  • @nicolasmayorga8288
    @nicolasmayorga8288 8 місяців тому +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 ❤

  • @lazyjoe597
    @lazyjoe597 7 місяців тому +45

    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

    • @jaromanda
      @jaromanda 7 місяців тому

      Firefox already has support for this - it's behind a flag for now

    • @lazyjoe597
      @lazyjoe597 7 місяців тому

      @@jaromanda the thing is that even if they'll bring these features in the very next update we still have to wait for quite some time. You can't expect your website's users to have the latest browsers updates and especially some feature flags on, duh. So with that you have to wait at least a few years to have at least 95%+ of your users with some features available before you can implement it

    • @gro967
      @gro967 3 місяці тому

      You can already uses it on the browser that is used by most of the world. For mobile where Safari exists, you would adjust the design anyway.

    • @lazyjoe597
      @lazyjoe597 3 місяці тому

      ​@@gro967 uhh, so what? Are you ok with leaving behind all Apple users just cuz there are more Chrome users? Nope, you won't do it if you have some common sense. Unlucky? Yeah, but you can just wait for it like we did with all other fancy things we can use rn in CSS.
      I just want to remind you about population of India (and south Asia overall) with most of Android users among them (95%+ and therefore Chrome users) and USA with lots of Apple users with a Safari browser (like a half of the USA population) and you should consider who is your target audience and with that given you decide whether you're gonna use some new features or don't

    • @gro967
      @gro967 3 місяці тому

      @@lazyjoe597 yes, just leave them out, that's exactly how reality works. Like I said, even on Mac, no one is using Safari, the biggest user group of Safari is mobile users, who should get a individual experience anyway.
      If Safari and Firefox don't support it than it is how it is.
      The worst thing that could happen is that the users push Mozilla and Apple to keep up with modern web standards.
      And of course in your app, place a very prominent banner after checking the browser, that this browser failed to implement modern standards.

  • @Theboredyellowstone
    @Theboredyellowstone 4 місяці тому +35

    got so hyped watching this video and so unhyped reading the comments 🥲

  • @jefker
    @jefker 6 місяців тому +20

    @keyframes appear {
    from {
    opacity: 0;
    scale: 0.5;
    }
    to {
    opacity: 1;
    scale: 1;
    }
    }
    .block {
    animation: appear linear;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
    }

  • @MacOSOperatingSystemUser
    @MacOSOperatingSystemUser 7 місяців тому +3

    No JS? You're a bloody genius!

  • @JensMartsch
    @JensMartsch 4 місяці тому +22

    This is not usable right now (September 2024) as it is only an experimental css property. It only works in Chromium based browsers and is subject to change. So use Intersection observer instead or something like the gread GSAP scrolltrigger or locomotive scroll.

  • @boomba118
    @boomba118 7 місяців тому +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

  • @mudyeet_
    @mudyeet_ 7 місяців тому +3

    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.

  • @SuperShootergame
    @SuperShootergame 6 місяців тому +9

    @keyframes appear {
    from {
    opacity: 0;
    clip-path: inset(100% 100% 0 0);
    }
    to {
    opacity: 1;
    clip-path: inset(0 0 0 0);
    }
    }
    .block {
    animation: appear linear;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
    }

  • @aryanisgood
    @aryanisgood 8 місяців тому +2

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

  • @xViiiZe
    @xViiiZe 8 місяців тому +3

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

  • @Rishankoiry
    @Rishankoiry 4 дні тому +2

    That was amazing !!!

  • @its.arjun.s
    @its.arjun.s 7 місяців тому +7

    I have no idea why people are mad? It's really 3 properties, and why does it matter that it's unsupported in many browsers? All CSS features starts off like that. There's even a polyfill for it. Great work!

    • @LuBre
      @LuBre 7 місяців тому

      Because it's not supported by Safari, which means "Apple users wont see anything".

    • @gregorimartinez361
      @gregorimartinez361 7 місяців тому +1

      Because it's clickbait with an experimental property. It's not even supported in Firefox yet

    • @UpthechelseaA
      @UpthechelseaA 7 місяців тому

      ​@@LuBre 😂😂😂

  • @PreCodeCamp
    @PreCodeCamp 17 днів тому +4

    Definitely, you provided an innovative approach to creating scroll-triggered animations, but it's not a standard CSS feature yet. The animation-timeline and animation-range properties are experimental features that aren't widely supported in current browsers (as of January 2025). These properties are part of the CSS Scroll-Linked Animations Module, which is still in development.

  • @parasmanku7536
    @parasmanku7536 5 місяців тому +8

    These are not 3 lines but still very easy. THX

  • @jaromanda
    @jaromanda 7 місяців тому +104

    Chrome experimental features should not be used in production

    • @vijaypawar1316
      @vijaypawar1316 7 місяців тому +1

      Meaning?

    • @jaromanda
      @jaromanda 7 місяців тому +7

      @@vijaypawar1316 have someone in the industry explain it to you.

    • @Wildwonderer
      @Wildwonderer 6 місяців тому +38

      ​@@vijaypawar1316
      Animation timeline is only known in chrome experimental features. It's does not exist in css, so if you were to use this in a real project. It's gonna suck

    • @vijaypawar1316
      @vijaypawar1316 6 місяців тому +3

      @@Wildwonderer okay, thank you 😊🙏🏼

    • @valhatan3907
      @valhatan3907 6 місяців тому +33

      ​@@Wildwondererthank you someone in the industry, you are more informational than the op

  • @victoriamarchi6973
    @victoriamarchi6973 8 місяців тому +1

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

  • @tylerpetrov8094
    @tylerpetrov8094 8 місяців тому +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!

  • @minolruckshan5396
    @minolruckshan5396 8 місяців тому +1

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

  • @edsHTML
    @edsHTML 7 місяців тому +1

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

  • @carbon_is_life
    @carbon_is_life 2 місяці тому +4

    Yup...that's a sub well deserved pal👌👌

  • @towercontrol4450
    @towercontrol4450 7 місяців тому +8

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

  • @cwirus99
    @cwirus99 8 місяців тому +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  8 місяців тому

      Sure I will try to mention that in future videos 🙂

    • @qewela
      @qewela 8 місяців тому

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

    • @vosyasabesquien
      @vosyasabesquien 8 місяців тому

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

    • @cwirus99
      @cwirus99 7 місяців тому

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

  • @blzspti909
    @blzspti909 6 місяців тому +7

    this is an experimental feature available in chromium-based browsers only.
    If you use it in production, Firefox and Safari users will experience issues.
    But it’ll be cool later down the line when it gets supported by non-chromium browsers.

  • @saranshparashar4257
    @saranshparashar4257 8 місяців тому +1

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

  • @gtavgraphicsdemo6987
    @gtavgraphicsdemo6987 3 місяці тому +2

    you saved my life bro for real 😍

  • @muhammad_zohaib936
    @muhammad_zohaib936 8 місяців тому +1

    Thanks a lot I needed that kinda explanation appreciated🙏❤

  • @oscarflavio7430
    @oscarflavio7430 4 місяці тому +1

    That was impressive. Thanks buddy, success!

  • @heshankumarasingha5742
    @heshankumarasingha5742 2 місяці тому +1

    You are a life saver man. Thank for the pro tips. Pit 😍😍

  • @SmartC2007
    @SmartC2007 8 місяців тому +2

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

  • @gabrielvasconcelos2166
    @gabrielvasconcelos2166 7 місяців тому

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

  • @iyxan23
    @iyxan23 6 місяців тому +14

    you should clearly point out that this is an experimental feature in chrome only

  • @MarcosDemian
    @MarcosDemian 7 місяців тому

    Awesome tutorial and to the point. Liked and subscribed

  • @RuTe-tr3bj
    @RuTe-tr3bj 8 місяців тому +2

    Awesome trick 👏👏

  • @merlinmeraldz
    @merlinmeraldz 7 місяців тому +3

    nice tip, hopefully firefox and safari support comes fast

    • @jaromanda
      @jaromanda 7 місяців тому

      available in firefox behind a flag, so, won't be long for firefox

  • @MuhammadShoaibOfficial
    @MuhammadShoaibOfficial 7 місяців тому +6

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

  • @tayyabafzal7296
    @tayyabafzal7296 4 місяці тому

    mind-blowing. After many time, I commented on youtube video.🖤🖤

  • @Acuce7ibd468j
    @Acuce7ibd468j 6 місяців тому +1

    You deserved a like because now no need to include the aos library ij my project.

  • @coding.py.
    @coding.py. 4 місяці тому +1

    00:01 Animate elements on scroll with 3 lines of CSS
    00:26 Creating an animation on scroll using 3 lines of CSS.
    00:48 Animate elements on scroll using CSS
    01:10 Elements animate individually based on scroll position
    01:28 Use the animation range property to trigger animation on element entry.
    01:46 Entry percentage affects animation timing
    02:09 Animation range property ensures completion by 40% viewport
    02:32 Animate elements to grow on scroll with CSS

  • @MrHarshilsharma
    @MrHarshilsharma 5 місяців тому +1

    Awesome! Once this is part of baseline, we'll no longer need JS AOS logic.

  • @Atul_Thakre30
    @Atul_Thakre30 8 місяців тому +1

    Thank you so much for this 🔥🔥

  • @ModderorWot-ci1zj
    @ModderorWot-ci1zj 8 днів тому +1

    Glad it's easier than scroll trigger with GSAP🤩🤩

  • @faizbyp
    @faizbyp 8 місяців тому

    thank you very much! this is exactly what I need

  • @thewebstylist
    @thewebstylist 8 місяців тому +1

    Amazing!

  • @nishantkr5759
    @nishantkr5759 8 місяців тому +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  8 місяців тому

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

    • @nishantkr5759
      @nishantkr5759 8 місяців тому

      @@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  8 місяців тому

      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 8 місяців тому

      @@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 UA-cam nor in Chat...

    • @Snippets_Code
      @Snippets_Code  8 місяців тому

      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. 🙂

  • @rahimrahim2720
    @rahimrahim2720 4 місяці тому +1

    wow that what i was looking for, thanks

  • @Lukaschenko-pv7kh
    @Lukaschenko-pv7kh 2 місяці тому

    Thank you for this video, it really helped me a lot! :)

  • @MohammadIslam-t5y
    @MohammadIslam-t5y 2 місяці тому +1

    ALHAMDULILLAH It's a great video. Very easy, thank you.

  • @ring11037
    @ring11037 7 місяців тому +6

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

  • @alexcostal3749
    @alexcostal3749 8 місяців тому +1

    Amazing

  • @angelfigueroa6662
    @angelfigueroa6662 5 місяців тому +1

    I would prefer to use intersectionObserver js API, it is a little more complicated but it has more compatibilitiy with browser versions

  • @VictorVictory-te2ij
    @VictorVictory-te2ij 6 місяців тому

    Awesome! Thank you so very much Sir!

  • @kevingonzalocruzmartinez8429
    @kevingonzalocruzmartinez8429 7 місяців тому +1

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

  • @ib4112
    @ib4112 7 місяців тому +1

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

  • @horaciomanuli
    @horaciomanuli 7 місяців тому +2

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

  • @Trendi_Vibes
    @Trendi_Vibes 6 місяців тому +1

    You king bro 🙌

  • @patriceaschen1324
    @patriceaschen1324 5 днів тому

    Thank you, very nice man

  • @uifry
    @uifry 8 місяців тому +1

    Amazing :)

  • @hemantharijan4431
    @hemantharijan4431 2 місяці тому

    thankyou for sharing this knowledge with us god bless you

  • @RajThakur-ol8mg
    @RajThakur-ol8mg 7 місяців тому

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

  • @mehdimansouri1547
    @mehdimansouri1547 8 місяців тому +1

    fantastic

  • @solongdygaming4729
    @solongdygaming4729 7 місяців тому +2

    Thanks you ❤

  • @teveoenlaweb
    @teveoenlaweb 20 днів тому +2

    Thanks a lot

  • @Esrar2024
    @Esrar2024 2 місяці тому +1

    it was useful and simple thank you so muck

  • @mohaymenul-islam
    @mohaymenul-islam 8 місяців тому +1

    awesome

  • @kellog89
    @kellog89 7 місяців тому

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

  • @joy-jitsu
    @joy-jitsu 7 місяців тому

    Nice idea 👌 thank you 🙏

  • @mr_harishv
    @mr_harishv 6 місяців тому

    Hats off.. nice trick and nice explanation

  • @YasirJabri
    @YasirJabri 8 місяців тому +1

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

  • @wlockuz4467
    @wlockuz4467 8 місяців тому +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  8 місяців тому +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 8 місяців тому

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

  • @LucasMorales-e2z
    @LucasMorales-e2z 7 місяців тому

    So cool and easy!

  • @itsatomtech
    @itsatomtech 8 місяців тому +2

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

  • @Rahul.Gurung.
    @Rahul.Gurung. 7 місяців тому +6

    Currently, this feature is only supported on opera, chrome and edge

    • @jaromanda
      @jaromanda 7 місяців тому +3

      or simply put, chromium

  • @Jamesolaa
    @Jamesolaa 5 місяців тому +1

    Is there a way to reverse this, so it comes in as you scroll in, could you make it come out as you scroll out? also great tutorial! Clear and concise :)

    • @Snippets_Code
      @Snippets_Code  5 місяців тому +1

      Sure, I will try that and let you know 🙂

    • @Jamesolaa
      @Jamesolaa 5 місяців тому

      @@Snippets_Code thank you! take care until then ✌️

    • @MohamedGamal-dq9el
      @MohamedGamal-dq9el 5 місяців тому +1

      Animate on scroll

      body {
      width: 100%;
      height: 1000vh;
      margin: 0;
      padding: 0;
      }
      h1 {
      width: 100%;
      height: 100vh;
      line-height: 80vh;
      text-align: center;
      display: block;
      font-size: 60px;
      }
      .view {
      width: 100%;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      justify-content: right;
      }
      .block {
      height: 500px;
      width: 10vw;
      box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px,
      rgba(0, 0, 0, 0.3) 0px 30px 60px -30px,
      rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;
      background-color: rgb(0, 0, 0);
      margin-inline: auto;
      filter: blur(4px);
      }
      @keyframes appear {
      0% {
      border-radius: 0;
      background-color: rgb(0, 0, 0);
      width: 10vw;
      filter: blur(4px);
      }
      50% {
      border-radius: 0;
      background-color: rgb(244, 44, 34);
      width: 90vw;
      filter: blur(0px);
      }
      100% {
      border-radius: 0;
      background-color: rgb(0, 0, 0);
      width: 10vw;
      filter: blur(4px);
      }
      }
      .block {
      animation: appear linear;
      animation-timeline: view();
      animation-range: entry 0% cover 100%;
      }



      Animate On Scroll




      what do you think about this ?

    • @MohamedGamal-dq9el
      @MohamedGamal-dq9el 5 місяців тому

      @@Snippets_Code take a look in my reply and give ur opinion

  • @Kittoopetto
    @Kittoopetto 6 місяців тому +1

    Thanks dude ❤

  • @JetPen
    @JetPen 6 місяців тому

    Cool bro! Aur bhai jisko dikkat hai jao tum js se karo. Ek toh bhai yaha kuch sikha raha hai aur idhar pade hai troll karne. Politeness karke bhi kuch chis hoti hai

  • @omarhassane638
    @omarhassane638 2 місяці тому

    You are the best 👍🏼

  • @LordieGoat-b2y
    @LordieGoat-b2y 8 місяців тому +1

    merci frr c tres utileee

  • @CristianKirk
    @CristianKirk 7 місяців тому +11

    Great but beware of browser support.

  • @edarcode8124
    @edarcode8124 3 місяці тому +2

    It's great, I've tried it and it works spectacularly, but with images, I didn't like it, it blocks the scroll while loading the image. With js the scroll doesn't block. Is there a way to fix this?

  • @usernameusernameusername12
    @usernameusernameusername12 8 місяців тому +2

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

    • @Snippets_Code
      @Snippets_Code  8 місяців тому +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 8 місяців тому +1

      @@Snippets_Code oh ok, thx! Great video 🙂

  • @ADITYAAAA
    @ADITYAAAA 2 місяці тому +5

    these properties isn't widely supported by browsers

  • @xaniar-x5c
    @xaniar-x5c 2 місяці тому +1

    thank you ❤

  • @ayangjibrut
    @ayangjibrut 3 місяці тому +3

    setiap liat tutorial dari orang asia selatan, mereka tuh ngasih informasinya kaya yang ikhlas ga ikhlas, ngelakuinnya setengah2, kaya terburu2, rusuh..

  • @blackpurple9163
    @blackpurple9163 8 місяців тому +4

    How's the browser support for these?

    • @Snippets_Code
      @Snippets_Code  8 місяців тому

      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 8 місяців тому

      @@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

  • @AhmedHuzain
    @AhmedHuzain 7 місяців тому

    Thanks a lot!

  • @otitologos
    @otitologos 24 дні тому +1

    No one can be perfect 🧐

  • @daedaluxe
    @daedaluxe 3 місяці тому +10

    3 lines of css?

  • @pobon97
    @pobon97 6 місяців тому

    You rock bro!

  • @victorcano6066
    @victorcano6066 7 місяців тому +2

    nice video bro! 🫶

  • @MauroAmador
    @MauroAmador 7 місяців тому +4

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

  • @satwikpanda2469
    @satwikpanda2469 8 місяців тому +1

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

  • @taufikdev
    @taufikdev 6 місяців тому

    Cool ! thanks bro

  • @KP-Kumar
    @KP-Kumar 2 місяці тому +1

    Thanks bro :)

  • @Iskael
    @Iskael 8 місяців тому +19

    can not run in Safari and Firefox

    • @Snippets_Code
      @Snippets_Code  8 місяців тому +8

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

    • @aldyreal
      @aldyreal 8 місяців тому +10

      You should notice this in the video btw

    • @perlixxx_
      @perlixxx_ 6 місяців тому

      who tf uses firefox?

    • @Pawfessor1
      @Pawfessor1 6 місяців тому

      don't use them

  • @NicMulvaneys
    @NicMulvaneys 7 місяців тому

    Nice! 🎉

  • @dominikrodler8010
    @dominikrodler8010 8 місяців тому +1

    sick