CSS Positioning: Position absolute and relative explained

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • CSS positioning properties can be a pain to understand. In this video, I look at the basics of Position Absolute, and how it's affected when we add Position Relative to a sibling and parent elements.
    Understanding how absolute positioning works in CSS will give you a huge boost to what you can accomplish in your designs!
    CodePen to follow along: codepen.io/kevinpowell/pen/jJ...
    ---
    New to Sass, or want to step up your game with it? I've got a course just for you: www.kevinpowell.co/learn-sass
    ---
    My Code Editor: VS Code - code.visualstudio.com/
    How my browser refreshes when I save: • How to automatically r...
    ---
    Support me on Patreon: / kevinpowell
    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 RUclips channel, make sure to follow me on Instagram and Twitter.
    Instagram: / kevinpowell.co
    Twitter: / kevinjpowell
    Codepen: codepen.io/kevinpowell/
    Github: github.com/kevin-powell

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

  • @stevenzhang8620
    @stevenzhang8620 2 года назад +38

    What I learned:
    1. position absolute will make the element jump out of document flow, other elements will basically ignore it.
    2. absolute is based to body by default, unless its parents has position relative.
    3. z-index to work with position relative.
    Thanks Kevin.

  • @munch6814
    @munch6814 5 лет назад +193

    This thing used to make my head hurt. Thanks a lot for explaining it clearly

  • @goldfinch5522
    @goldfinch5522 4 года назад +207

    my whole life was a struggle with CSS cause I never give my self time to learn it instead it was usually a process of trial and error, thank you Kevin your videos are very very helpful

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

      Unlike other languages, you can't learn CSS using trial and error. It's just too complicated to be able to do that. Speaking from experience 🤣

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

      I always want to go from beginner to expert in 2 steps instead of using as many steps as possible and learning the fundamentals

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

      Yeah me too , this video helped a lot

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

      @@kavinbharathi I can't even consider CSS like a language

    • @0x7F9B2A
      @0x7F9B2A 9 месяцев назад

      what do you consider it then?@@selhichakib

  • @RameenFallschirmjager
    @RameenFallschirmjager 4 года назад +90

    Although quality is a relative subject, the quality of this channel is absolutely superb!

  • @AJ-jj1gs
    @AJ-jj1gs 4 года назад +50

    I pick up a level of understanding on each subject from watching one of your videos that I wasn't able to achieve through an entire college course that covered the exact same material. I was using both absolute/relative positioning and the z-index on my creations but didn't have a completely clear understanding of exactly how they worked and simply used trial and error until they performed how I wanted them to. Thank you for explaining things in such a clear, concise, and logical manner.

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

      Same here. I am in a bootcamp. But the explanation here are better than my instructor's. The instructor knew how to use it by trial and error but couldn't explain it well like thiis. Thank you

    • @4MXW
      @4MXW 2 года назад

      Jaja I still do the same trial and error tactic... I hate not being able to understand what I’m doing... this explanations are on another level.

  • @KENAXION88
    @KENAXION88 3 года назад +30

    This video is absolutely amazing. I had a half way decent understanding of position absolute and relative, but now it makes complete sense! Thank you!

  • @DaWali1000
    @DaWali1000 5 лет назад +599

    My mom enters my room and a grown man talks about playing around with the child, well...

    • @siamonadi7997
      @siamonadi7997 5 лет назад +31

      you have the dirtiest mind of all human beings ever

    • @myriam5662
      @myriam5662 3 года назад +8

      😂😂

    • @vanman118
      @vanman118 3 года назад +18

      lol i heard that and was instantly like
      *hold up.*

    • @tiqo8549
      @tiqo8549 3 года назад +4

      😅

    • @FM-zr1rw
      @FM-zr1rw 3 года назад +11

      lol its youtube not darkweb 😂🙌

  • @zainabedin9842
    @zainabedin9842 4 года назад +6

    I was struggling with this concept for years and you managed to explain it so simply. Thanks

  • @ashimgautam4137
    @ashimgautam4137 Год назад +1

    Just know that Devs around the world don't take you for granted. Your videos help me keep my job.

  • @jasonwang5085
    @jasonwang5085 3 года назад +7

    Best explaination I have seen so far. Very clear and easy understanding. Thank you for the video mate!

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

    I love the way you explain things, simple, no over explaining.... THANK YOU

  • @JIu4Ho
    @JIu4Ho Год назад +7

    Your channel is a gem for someone who is learning CSS

  • @sridharbelide
    @sridharbelide 6 лет назад +155

    Actually position:absolute will look for non-static parent not only parent with position:relative

    • @KevinPowell
      @KevinPowell  6 лет назад +49

      Yup, you're right, it was an oversight of mine when I mentioned that :\

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

      sridhar belide then if we have a parent with position: absolute and the child with also position: absolute will that will lock that child element inside it ? If we specified the top, bottom, right and left value?

    • @cristiantorres3303
      @cristiantorres3303 5 лет назад +7

      WHAT NON-static means?

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

      @@cristiantorres3303 "static" is one of the possible values for the position property. Here's the full list ...
      position: static|absolute|fixed|relative|sticky|initial|inherit;

    • @tolstoievski4926
      @tolstoievski4926 5 лет назад +8

      sticky is cool for example if you want your hamburger or your menu be here anywhere you scroll to the page

  • @TWspk66
    @TWspk66 3 года назад +5

    The most clear explanation of "relative" & "absolute".
    Thanks!!

  • @BigFatSandwitch
    @BigFatSandwitch 3 года назад +4

    I watched several other videos on youtube but this is by far the best in explaining css positioning. Loved it

  • @baileyreyes8768
    @baileyreyes8768 5 лет назад +8

    This video is a gem. Mystery solved. Thank you, I would love to see more videos like this one!

  • @zlatasupinka
    @zlatasupinka 5 лет назад +7

    This is truly awesome! Thanks - you just saved me hours searching for a solution!

  • @Dextergec413
    @Dextergec413 3 года назад +2

    You have a talent for explaining some difficult concepts in an easy to understand way. Thanks so much for this, I was dealing the other day with a freecodecamp project where I had to have a responsive youtube video and I had to use an absolute child inside of a relative parent wrapper. this helps explain what I was trying to do so well!

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

    I was cruising right along in my CSS class until I hit this topic. You explain it well, but I’m still wrapping my head around it.

  • @Fatima-zd4el
    @Fatima-zd4el 2 года назад +3

    thank you so much for this!! I never used position absolute because I could never really understand how it worked. Really love the way you explain things, thank you so much Kevin!!

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

    I have watched several videos trying to understand absolute positioning. It confused me that writing the absolute property on one element, results in repositioning of a different element. I watched half of this video and it has already registered. Sometimes it's all about the teacher. THANK YOU!!!

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

    I am a fan from 2022, and seeing how far you've become with your journey, the way you speak now boasts confidence and I love it.

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

    Accurate, concise definitions and clear, illustrative examples! Very well done!

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

    I love this short format. Just one topic here and there. Keep up the great work

  • @aniketsatpathy1532
    @aniketsatpathy1532 Месяц назад +1

    I used to think that such things are heavy to understand until I watched your video.
    Thanks a lot for making such video and these are really helpful for beginners
    thank you Again
    Love from India

  • @mrx-qi8th
    @mrx-qi8th 3 года назад +1

    dk how to thank u,this video is literally 3 years old and i watched it about a month a go. But today i was able to put this knowledge to actual use in an actual peoject. So wanna thank u again for sharing ur knowledge.you're an awesome teacher. And to other people if u ever needed to pos:abs more than one element just put all elements inside a div and apply pos:abs to one div instead of to 3,4 elements. Love u man ,stay safe

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

    Thank you for the video...was trying to find an article/video where someone explains the concept of absolute vs relative in a simple way.

  • @forrestalward3312
    @forrestalward3312 3 года назад +1

    Thanks for this! I have been confused on this concept for a while now and this video just gave me that penny dropping moment where I now understand! great resource and really makes it simple for new SE

  • @michaelthum3575
    @michaelthum3575 8 месяцев назад

    Your videos explain in 5 minutes these concepts, where I have spent hours searching through documentation. Many Thanks

  • @hiddenwasabi
    @hiddenwasabi 3 года назад +2

    Very concise, clear and easy to understand. Thank you so much for this video!

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

    This really explained LOTS of things! And made me subscribe immediately.

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

    Awesome mate. Thanks for taking the time to make the vid and beautiful example/ explanation.

  • @sinansalameh
    @sinansalameh 4 года назад +3

    Finally, some one explains this very simply, big thanks Kevin.

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

    Thanks Kevin! This is one of the simplest explanations I have come across!

  • @holycrapluvthisvid
    @holycrapluvthisvid 2 года назад +3

    I'm learning CSS right now and could not wrap my head around this concept. You just cleared it up I wish I could like this 10 times

  • @joycemeow5857
    @joycemeow5857 3 года назад +1

    You're the best! I learned so much from you! Really like the way you teach, very clear and concise!

  • @Kristen_85
    @Kristen_85 6 лет назад +1

    Hey Kevin! I just started watching some of your videos today and so far they have been really helpful! Thanks!

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

    2½ after posting this video and it's still helping people. Awesome explanation of relative positioning. I don't know why, but it's always been a challenge for me to "get it." I'm much closer now than before I clicked "play." Thank you Kevin.

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

    Thank you Kevin, I could not quite understand position and relative but you explained it in a way that works for me

  • @bikibalami4829
    @bikibalami4829 3 месяца назад

    Been 2 years i was confused about this. Why dont other tutorials make it this simple. no one told me it looks for the closest parent with relative positioning. This solves everything. thanks.

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

    Thank you for taking the time to post this video. It was very helpful.

  • @Britney.J
    @Britney.J Год назад

    Yes! thank you! I don't do front-end work every day and always forget this.

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

    Dude. Thank you so much for this video.... I had no idea how this worked and now I completely understand. Been bingeing your videos. Thanks for all the help on all the CSS mysteries.

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

    Thanks, man. That was a great video! And the tip about the z-index was also really helpful :)

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

    thank you for this, I had my boss ask for an absolutely positioned element and I thought she was crazy, having a relative parent will make this work just like she wanted it.

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

    Gosh! The simplicity with which you explained it, thanks a lot!

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

    Bra, I love you. I always forget the difference between absolute and relative but I just come back to this video of yours. :)

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

    This explanation was the best I have seen on youtube. Kudos to you.

  • @adam-user
    @adam-user 11 месяцев назад

    Kevin, you are a genius in explaining CSS a simple way. I never understood position absolute/relative - until TODAY. Thanks!

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

    I found your videos through a HTML/CSS course called Odin Project. I have been poking around with websites since the WYSIWYG Macromedia Dreamweaver days and trying to learn to code CSS on and off through the years. Then came devices and things got even more complicated with responsive websites. I gave up for awhile due to this, every time I tried to create something it was a mess. Your videos have made everything click instantly for me. I feel more confident in creating websites that will work on all devices and just more confident in my coding ability overall. THANK YOU SO MUCH

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

    Great video! Exactly what I needed to add a button to the middle of a container with a header image. Thank you!

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

    Simple and explained in detail. I was finding difficult in understanding relative and absolute. After see this I can very well use this. Thanks for the post

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

    Thank you Kevin ! I always confuse about absolute and relative position. I got better understanding of how they work after this video.

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

    Oh man thanks! I'm going through Codecademy right now and I'm on this section. we'll it was confusing cause everything is given in written format with still images. this REALLY helped me grasp the concept way better. really grateful.

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

    Wow, the first of about ten videos that finally made it clear. I wish yours had been the first! I'd like to thank you :before and :after.

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

    Hi Kevin, Thank you so much and massively grateful to you. you made things making sense and clear, you are a great teacher

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

    I come here every now and then to refresh my knowledge on CSS Positioning. Cheers!

  • @arthy7901
    @arthy7901 3 года назад +1

    Thank you for this explanations, you made it so easy to understand!!

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

    I'm watching this video using the school's computer, and I only signed in just so I can give it a like. It's really worth it. Thank you so much

  • @Kevin-lh3ig
    @Kevin-lh3ig 2 года назад

    After really watching 3 videos, I finally understood relative and position. Love your content and keep it going.

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

    Absolute clarity in your explanation. Keep it up and thank you.

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

    3 minutes in and I’m already thanking you for taking the time to explain exactly what the properties mean in a way I can easily grasp.
    #Subscribed

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

    Thanks man. You help me a lot with this. Good luck with your channel

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

    Exact what I was waiting for and always wanted to know. I am a senior webdesigner, but still learn. Thank you!

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

    your tutorials are always so helpful. thanks!

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

    this was the best explanation I've seen about css positioning! thanks a million!!

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

    I have never understood this, until now. You are a pro teacher.

  • @FourGamingILFGIL4Fever
    @FourGamingILFGIL4Fever 3 года назад +1

    THANK YOU!
    The best tutorial I've seen so far.

  • @revillsimon
    @revillsimon 6 лет назад

    really helpful - i get it now, thanks for making this video. Watched your other tutorials too, they're great. Keep them coming!

    • @KevinPowell
      @KevinPowell  6 лет назад +1

      Very great, glad that it helped, and that you've been enjoying my content :)

  • @1024gain
    @1024gain 2 года назад

    That background you have there just burns my eyes so much. Maybe i should go out more often :D. Great video btw

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

    I finally understand position relative and absolute! Thank you!

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

    Great Video! thanks for sharing your knowledge in such a great way.

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

    I love the way you explained it! Well done!

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

    Thank you! You were able to help me understand. I tried googling the different between absolute and relative but I kept getting these complicated explanations.

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

    really love this, thanks for making the video!!

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

    Thanks Kevin. Your Videos always helps to understand the basic concept of CSS.

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

    Thank you for explaining this in such short yet clear way

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

    Kevin! Nice video - I LIKE the 5 minute format videos. Helpful without getting lost in the weeds....

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

    Been struggling with for a week now... And yo vid made it hella simple 💯
    Thank you very much 👌🏽 🔥

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

    This makes a lot more sense than the convoluted explanations ive read in the past.

  • @excelapplications6969
    @excelapplications6969 5 лет назад +4

    Thank you very much for the great explanation.

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

    I love you for making these videos so easy to understand

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

    Perfectly explained, this topic used to hurt my head so much, not anymore, thank you!

  • @Anatolii-
    @Anatolii- Год назад

    Great explanation! Without pushing a sale on you. Much appreciated!

  • @VinhNguyen-ul8yg
    @VinhNguyen-ul8yg 2 года назад

    Boom, just what I needed to finally understand position relative and absolute. Thanks Kevin.

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

    I've watched this video before
    Today I got stuck at trying to nest my child element in the parent div but margin top was creating a space between the previous div and the current one which am working on.
    I came back to watch this video and voila, all set 🙌
    I've been on this since last night, till 2AM but couldn't figure it out. Now it's almost 4PM and that's when your video came in handy.
    Thanks a lot man
    A new subscriber is in your list now 🙇

  • @seanpheneger6632
    @seanpheneger6632 6 лет назад +1

    Very good explanations on these concepts. I've watched about half a dozen videos on this topic and always come away a little cloudy...until now! Thank you

  • @AmitKumar-ft7em
    @AmitKumar-ft7em 4 года назад

    thank you so freaking much i had been scratching my head form last 4-5 months read different articles saw a couple of videos on this topic but none of them helped me understand that how are these related and as well as different from each other and most importantly after watching this video i know how and when to use absolute.

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

    Best tutorial on positioning I have seen so far.

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

    Actually man u deserves a big thumbs up every time your videos really help me a lot liked and subscribed

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

    wonderful and simple explanation!!!!! KUDOS to you Kevin !!!!

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

    I'm finally getting the hang of positioning and it's coming in handy for doing different layouts with bootstrap

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

    The most clear explanation of "relative" & "absolute".
    Thanks!!🤩🤩

  • @Aliante4
    @Aliante4 Год назад +1

    That was so helpful!!! I didn't know the parent having a relative state would determine the child's positions. This clears up a lot of confusion

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

    Thank you so much, I couldn't understand ANYTHING before, but this is so clear and helpful 🙏🏽

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

    I've been studying web design for over six months already and was struggling with a layout I am currently working on. This was very useful, gave me some ideas. Thank you, Kevin.

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

    This is the most helpful video so far!! Thank you :)

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

    BRO THANKYOU THANKYOU SO FLOWERING MUCH I WAS SO CONFUSED ABOUT POSITION ABSOLUTE AND RESEARCHED A LOT BUT YOU GOT THE CONCEPT CLEAR IN MY HEAD! I am subbing sire!

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

    The best of all explanations! I immediately purchased your course at Scrimba as a token of appreciation (though you've equally good quality videos in your YT channel)

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

      Glad you liked it and thanks for getting the course, hope you enjoy it!

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

    Thanks for making this concept easy to understand 👍🏾