The Forgotten CSS Position

Поделиться
HTML-код
  • Опубликовано: 13 июн 2024
  • 🚨 IMPORTANT:
    Learn CSS Today Course: courses.webdevsimplified.com/...
    Everyone knows how to use relative, absolute, and fixed positioning in CSS, but most people don't even know about the amazing sticky position. Sticky position is a unique hybrid between relative and fixed position and makes creating elements that only act liked fixed elements after they are scrolled to a certain point incredibly easy. This used to be something that could only be accomplished in JavaScript, but sticky position makes it possible in CSS, and is much better for web performance.
    CodePen For Sticky Header:
    codepen.io/WebDevSimplified/p...
    CodePen For Sticky List Headers:
    codepen.io/WebDevSimplified/p...
    Twitter:
    / devsimplified
    GitHub:
    github.com/WebDevSimplified
    CodePen:
    codepen.io/WebDevSimplified
    #CSSTips #WebDevelopment #Programming

Комментарии • 155

  • @WebDevSimplified
    @WebDevSimplified  5 лет назад +61

    Just a note on why I used @supports at the end of the video. If a browser does not support position: sticky it will fallback to position: static instead of position: relative which will make any absolute positioned elements inside the sticky positioned element no longer work properly.

  • @techuchiha6510
    @techuchiha6510 5 лет назад +76

    Simple, Precise and to the point ✌🏻

  • @sinc1802
    @sinc1802 2 года назад +22

    Although this video is like 3 years old, it helped me a lot. I was in a desperate moment on how to make my navbar fixed but somehow still relatively positioned according to other elements. The first example in this video is EXACTLY what I was looking for for the past one week. Thank you very much!!

  • @alfredyeh3553
    @alfredyeh3553 4 года назад +24

    just learning html and this vid was godsent. I hope everyone starting out can watch your videos

  • @yangyu4489
    @yangyu4489 4 года назад +5

    Such a good series!!! Thank you for your hard work!

  • @why-mope
    @why-mope 4 года назад

    Great explanations, and the details of how sticky works! Thanks for the comprehensive video.

  • @MG-bm5oj
    @MG-bm5oj 4 года назад +1

    Great tutorials. Well explained and going straight away to the point.

  • @suza7383
    @suza7383 4 года назад +1

    Thanks for the explanation,, it was great! I was so confused until now.

  • @christine5906
    @christine5906 3 года назад +3

    Thank you so much for this. I've been struggling to do this in JavaScript. This is simple yet super helpful. You saved me. Thank you so much.

  • @matthewsjardine
    @matthewsjardine 2 года назад +2

    This is super cool, and much simpler than I thought it would be. This channel is gold for a noob like me. Thank you for your videos!

  • @SpencerTaylorOnline
    @SpencerTaylorOnline 2 года назад

    This is the best description and instructions on how to use Sticky Position in almost all browsers I have seen.

  • @AlexTechie
    @AlexTechie 5 лет назад +13

    Thank you for this video. I've been learning nav bars and I had the same problem you talked about when using Fixed, where the elements below the navbar get bumped up. I didn't know if this is how people were doing it, but I used Fixed because I only know about Fixed+Relative+Absolute. Now, I know to use Sticky, instead. 👍

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +6

      Sticky is so much nicer to work with than fixed. I hate having to add margins to my content when using fixed because it just doesn't seem right. Just make sure that you check to see if the browser supports sticky position using @supports because it isn't supported in all browsers yet.

    • @AlexTechie
      @AlexTechie 5 лет назад +2

      For sure; that's probably one of the reasons I hadn't heard of it before (even though 90% browser support with prefixes sounds pretty good. IMO). BTW, have you done a video on an image slideshow w/ autoplay + pause + left / right arrows? I'm gonna check right now, but figure I'd include it in this comment instead of messaging you twice.

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +3

      Yeh 90% really is pretty good. I thought it was around 80 for some reason. As for the image slider, I have not done a video on that topic but there are tons of videos about that so you should be able to find a good one.

  • @Dexquest3d
    @Dexquest3d Год назад

    thank you for this video, it's really clarified some unknowns for me

  • @pensivefuu1885
    @pensivefuu1885 4 года назад

    Super helpful, incredibly simple and easy to understand.

  • @wanderdutts4584
    @wanderdutts4584 2 года назад

    Brilliant, love the sticky list headers. I will be using this method next time someone wants a sticky bar, instead of having to mess around with JS!

  • @MichaelCampbell01
    @MichaelCampbell01 4 года назад +1

    I really do like these short, digestable videos where possible.

  • @devendrajadhav8538
    @devendrajadhav8538 3 года назад

    Thank you so much for this wonderful tutorial it helps a lot

  • @josephkatongole4659
    @josephkatongole4659 4 года назад

    Thank you for this video. It’s really precisely helpful

  • @justinseegets9629
    @justinseegets9629 2 года назад

    Thank you very much for providing these videos!

  • @mandalorian99
    @mandalorian99 2 года назад

    Best example how and why to use sticky! Great stuff!

  • @reza.kargar
    @reza.kargar 2 года назад

    The example you have provided is extremely useful for teaching this concept, awesome

  • @soultouchingsongs
    @soultouchingsongs 4 года назад

    Full of awesomeness. You are a great tutor. Bless You.

  • @mezirezi1
    @mezirezi1 4 года назад

    Thanks mate; I only knew how to do stiky on excel, now html. I am using that on my current mid term project.

  • @patrickc.6183
    @patrickc.6183 5 лет назад +3

    Great explanation of position: sticky! I really like your CSS content!

  • @sapindersingh1165
    @sapindersingh1165 3 года назад

    You're really a fantastic teacher. Keep it up!

  • @jackrobertson9916
    @jackrobertson9916 Год назад

    dude your contents are forever. great job

  • @hoyinli7462
    @hoyinli7462 2 года назад

    really recommend this channel. he did extraordinary works!

  • @karthikeyan878
    @karthikeyan878 4 года назад

    Clear Explanation !! Thanks a lot

  • @ferozalimeghani2561
    @ferozalimeghani2561 2 года назад

    Vert informative video to understand sticky position. Well done.

  • @codebitcookie8053
    @codebitcookie8053 Год назад

    Thanks a lot. Love your videos.

  • @buithanhlam3726
    @buithanhlam3726 3 года назад

    Great explaination!

  • @sai6157
    @sai6157 2 года назад

    Thank you so much, this video made my day ❤️

  • @nanitechinfo6188
    @nanitechinfo6188 4 года назад

    One best sticky simple video I searched lot I got this is the best

  • @josue-cedeno
    @josue-cedeno 3 года назад

    Short, concise videos are the best!

  • @PawanKumar-tu6ti
    @PawanKumar-tu6ti 3 года назад

    Thanks brother, you helped me!

  • @joseglm
    @joseglm 5 лет назад +2

    Great, very practical video, keep them coming!

  • @gelsonwork
    @gelsonwork 5 месяцев назад

    Finally, I've understood the concept of sticky position.
    My warmest thanks ❤❤

  • @nemesioansorin
    @nemesioansorin Год назад

    super useful - I was doing this for years using javascript :) ...

  • @annismonadjem6901
    @annismonadjem6901 4 года назад

    Great video! Thanks.

  • @MubashirullahD
    @MubashirullahD Год назад

    So well explained

  • @ganesan.r5430
    @ganesan.r5430 2 года назад

    thanks a lot, now I know what is @supports used for, explain more such CSS tips.

  • @bertilow
    @bertilow 4 года назад

    Very well explained. Thank you!

  • @manish-mk
    @manish-mk Год назад

    What a precise explanation !

  • @noirsociety
    @noirsociety 4 года назад +1

    A thousand thanks to you Web Dev Simplified :)

  • @techiesrikanth2447
    @techiesrikanth2447 3 года назад

    Great content.
    Thanks

  • @AmmarAhmey
    @AmmarAhmey 4 года назад

    Great .. easy.. awesome explanation :)

  • @alimohammadi1517
    @alimohammadi1517 3 года назад

    Great vid man , subed

  • @Vega004
    @Vega004 2 года назад

    Thanks again buddy👍

  • @sheikabdullah8209
    @sheikabdullah8209 3 года назад

    Really u r super 👍., No words to say ur teaching., Keep rocking bro 👍

  • @hamzajirah4856
    @hamzajirah4856 4 года назад +8

    I have found yet another genius. Thanks for this content and many others that have helped me understand some #WebDevelopment concepts better.

  • @ANILKUMAR-ye3rq
    @ANILKUMAR-ye3rq 4 года назад

    Thankyou very much .

  • @forexspectrum4799
    @forexspectrum4799 4 месяца назад

    Thanks a lot sir ❤

  • @palachokrab5711
    @palachokrab5711 2 года назад

    Beautiful n clean

  • @adalovelac24
    @adalovelac24 2 года назад

    very useful thanks

  • @dalmecsystems1251
    @dalmecsystems1251 3 года назад

    Excellent video! Thanks for posting! Can this be used to make items stick on the left too? I'm thinking of spreadsheet-style columns that stay on the left as you scroll across.

  • @kazimuntasir
    @kazimuntasir Год назад

    Surely I enjoyed very much.❤

  • @sakshamchhatkuli271
    @sakshamchhatkuli271 3 года назад

    Thank you so much

  • @codespector1989
    @codespector1989 4 года назад +1

    its a great explanation of position:sticky. Thanks
    DO you know any resources/templates for practice to become a professional web designer

  • @tonynunes1496
    @tonynunes1496 4 года назад

    nice
    didactic, thank you!!!

  • @starjohnson3040
    @starjohnson3040 Год назад

    Simple and clean

  • @AutomationTank
    @AutomationTank 4 года назад

    I would like to repeat the same thing as @TechUchiha said "Simple, Precise and to the point" 👍. Great Job, Keep it up :)
    I am not from the coding background but this made me very clear regarding my doubt. Thanks!

  • @christianvargan6015
    @christianvargan6015 5 лет назад +1

    Thank you so much!

  • @TechTVanshumangogate
    @TechTVanshumangogate 11 месяцев назад

    Really helpful

  • @kirankothandan5529
    @kirankothandan5529 3 года назад

    Absolutely gold

  • @santhoshn3766
    @santhoshn3766 3 года назад

    Thanks!

  • @parasarora5869
    @parasarora5869 5 лет назад

    nice video...glad to see it😄 ... now i know more about sticky position. thank you kyle✌

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      Thanks for giving me the idea for the video!

    • @parasarora5869
      @parasarora5869 5 лет назад

      @@WebDevSimplified no problem... I will wait for the next video😁

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +1

      @@parasarora5869 it will be out in just over 24 hours.

    • @parasarora5869
      @parasarora5869 5 лет назад

      @@WebDevSimplifiedI will definitely see that...thanks for info😄

  • @negritoojosclaros
    @negritoojosclaros 4 года назад +4

    you've save my life.

  • @emuemhonjieonosereme2495
    @emuemhonjieonosereme2495 Год назад

    Thank you

  • @mateenahmedkhan3780
    @mateenahmedkhan3780 4 года назад

    i didnt know about @support :+1 for it!

  • @albenideslyma
    @albenideslyma 4 года назад +2

    Obrigado amigo, ajudou muito.
    Ganhou mais um inscrito.

    • @ed1nh0
      @ed1nh0 4 года назад

      What about thank him in his language?

    • @mobileking3911
      @mobileking3911 Год назад

      @@ed1nh0 😂😂😂

  • @WeLoveSpigotPlugins
    @WeLoveSpigotPlugins 4 месяца назад

    Thanks :D

  • @noob.gamers.official
    @noob.gamers.official 4 года назад

    Please make a video for display elements.

  • @anurajms
    @anurajms Год назад

    thank you

  • @khushwindersingh2541
    @khushwindersingh2541 3 года назад

    Very useful

  • @ianfischer103
    @ianfischer103 4 года назад

    Position: sticky look professional the way you have the header and then the navbar. I enjoyed this video.

  • @GyanaranjanPatiMCA
    @GyanaranjanPatiMCA 2 года назад

    Thx bhai

  • @kaiixerhub
    @kaiixerhub 3 года назад

    Can I use this sticky position on a tag?

  • @TomNuorivaara
    @TomNuorivaara 5 лет назад +17

    Great tutorial! You might want to include the word "sticky" in the video title for SEO purposes :)

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +6

      Thanks for the feedback. I was trying something different with the title and thumbnail to see how it works. I'm always trying to experiment to find the best way to do things.

  • @himankverma125
    @himankverma125 2 года назад

    thanks

  • @bhatnagarcapital
    @bhatnagarcapital 4 года назад

    best ! you are the best !

  • @afullstackboss8481
    @afullstackboss8481 3 года назад

    Hello Kyle, can you make a video on xpath with html, css and javascript demo project? Thanks

  • @oussamamoussaoui5821
    @oussamamoussaoui5821 3 года назад

    Always the best

  • @axelandru9346
    @axelandru9346 6 месяцев назад

    🎉 game changer !

  • @kams196
    @kams196 3 года назад

    How did the image appeared in the heading just by adding the

  • @DjCppsNews2012
    @DjCppsNews2012 4 месяца назад

    Question: Why do you use the style tag instead of a separate CSS file? Wouldn't that violate separation of concerns? Is it more for tutorial sake so that you aren't flipping between files constantly while explaining and demonstrating your examples? (Which would make sense if that were the case)

  • @mubafaw
    @mubafaw 2 года назад

    You're the truth 👍

  • @exploringgnawing3248
    @exploringgnawing3248 3 года назад

    How do you stop this from bleeding into your footer? (ie. part of a sidebar?)

  • @zakibonfoh6287
    @zakibonfoh6287 4 года назад

    You're the G.O.A.T!

  • @aadeekale
    @aadeekale 2 года назад +1

    how .header-large gave that image in the body even if the div isn't styled in css or style

  • @Star-zf8su
    @Star-zf8su 4 года назад

    Lol....I used to use JavaScript for this simple stuff thanks very much for sharing

  • @cripler4732
    @cripler4732 3 года назад

    cool good job buddy

  • @pulkitgupta5039
    @pulkitgupta5039 3 года назад

    When I am using position: sticky element stack up on each other and then, I am using background-color: transparent last one is visible. But in the video he said " it no longer remain fixed".

  • @astuces.tech2.0
    @astuces.tech2.0 Год назад

    1:43 Where this image come from though ?

  • @stupidname638
    @stupidname638 4 года назад +1

    You said that sticky falls back to relative when not supported by the browser so then why to we need to use that @support part when it will automatically become relative anyways if not supported by the browser ?

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +1

      This is because by default elements are static position so if it falls back to relative position you could get some weird bugs where the top/left/right/bottom values you specify on the element cause it to perform strangely in non-supported browsers.

  • @modex98
    @modex98 4 года назад

    the best teacher ever

  • @ivoatanasov5907
    @ivoatanasov5907 2 года назад

    Can we use js in case which sticky is not supported ?

  • @mudyeet_
    @mudyeet_ 3 года назад

    god that was great!

  • @DeepThinker193
    @DeepThinker193 4 года назад

    Wow, was about to use JQuery for this simple task as I'm noob. But this saved me.

  • @sent4dc
    @sent4dc 4 года назад

    Oh, that's what I hated about web dev -- browser support headache!
    Btw, what IDE are you using? Is it VS Code?

  • @Pareshbpatel
    @Pareshbpatel 3 года назад

    Excellent explanation. Thanks.
    {2021-05-28 09:56}