Why adding a margin on a child element affects the parent

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • 🔥 My course: Responsive Design for Beginners! coder-coder.co...
    💻 Become a full-stack web dev with Zero to Mastery: academy.zeroto...
    In this video I'll explain why adding margin-top to a child element sometimes moves the parent element down and creates a white space, what margin collapse is, and how you can fix it.
    ____________________________
    SUPPORT THE CHANNEL
    ⭐ Join channel members and get perks: / @thecodercoder
    👏🏽 Hit the THANKS button in any video!
    🎨 Get my VS Code theme: marketplace.vi...
    WANT TO LEARN WEB DEV?
    Check out my courses:
    🌟 Responsive Design for Beginners: coder-coder.co...
    🌟 Gulp for Beginners: coder-coder.co...
    RECOMMENDATIONS
    ⌨ My keyboard, Vissles V84 -- vissles.com/?r... -- 🔥 get 10% off with code THECODERCODER --
    💻 Other gear -- www.amazon.com...
    📚 My Favorite Books -- coder-coder.co...
    📺 My Favorite Courses -- coder-coder.co...
    🔽 FOLLOW CODER CODER
    Blog -- coder-coder.com/
    Twitter -- / thecodercoder
    Instagram -- / thecodercoder
    #webdevelopment #coding #programming

КОМЕНТАРІ • 26

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

    How do you come up with such brilliant and humorous thumbnails recently?? 😂😂

  • @squ34ky
    @squ34ky 11 місяців тому +6

    The animations are very helpful in visualizing what's actually going on.

  • @harunjonuzi
    @harunjonuzi 11 місяців тому +5

    This channel is a literal gem, I know it might take alot of time to produce quality content like this, but in the long run it will be worth it, keep up the good work, we are in love with the channel!

  • @boopathyraj6811
    @boopathyraj6811 11 місяців тому +3

    where were you?

  • @coreyzamprogno5510
    @coreyzamprogno5510 11 місяців тому +3

    Good to see you're coming back with some content! We've missed ya

  • @janiskarasa3707
    @janiskarasa3707 11 місяців тому +2

    This is very valuable content. I liked the one with images and white space underneath them.
    Next one could be about overflow, -x, -y for images and elements that are sticking out the viewports.
    Thank you! 🙏

  • @pranavgoel29
    @pranavgoel29 11 місяців тому +1

    I wasn't aware about display: flow-root, I use padding generally. There are a lot of things in CSS phew. hahaha
    This was insightful. 🤗

  • @ImAFriendlyMushroom
    @ImAFriendlyMushroom 11 місяців тому +2

    i’m so glad that you’re posting videos again!!! your channel has been so helpful during my coding journey and i’ve missed seeing you! thank you for all that you do, your efforts are so appreciated ❤

  • @juanmacias5922
    @juanmacias5922 11 місяців тому +1

    I always just used padding lol

  • @TravieTrav
    @TravieTrav 11 місяців тому +2

    this video came out right on time. was just struggling with this last night!

  • @Alejandro00710
    @Alejandro00710 11 місяців тому +1

    It's great to see you again, you been away for a long time, hope your channel growts as it deservs.

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

    im trying to understand how in the beginning you say adding the margin-top in the second element to try and add space between the first and second element while maintaining the background colors touching. i get why it adds the white part but im not understanding how it correlates to the phenomenon of margin collapse? wouldn't it just be you are using the wrong property for the current problem and having nothing to do with margin collapse because there is no margin being applied to the first element to even have margin collapse phenomenon from happening between first and second element? sorry i just want to know if this is a mistake or if this is true that this is in fact margin collapse.

  • @Dailyz.
    @Dailyz. 11 місяців тому +1

    Your videos are incredibly helpfull ❤

  • @moroccoheaventours304
    @moroccoheaventours304 11 місяців тому

    Hi please I have a problem in my website not mobile friendly in google I need your help if it possible many thinks

  • @betoreyes3564
    @betoreyes3564 11 місяців тому

    Great video!, greetings from Mexico!

  • @jimmyandres711
    @jimmyandres711 11 місяців тому

    my favourite teacher is back

  • @arefakminasi2626
    @arefakminasi2626 11 місяців тому

    Incredibly helpfull

  • @VoloInTech
    @VoloInTech 11 місяців тому

  • @ridir2912
    @ridir2912 11 місяців тому

    Margin-Collapse is some next Level CSS-Vodoo-Magic and the reason why our boss told us to avoid using margin. Thank you for demystifying such behavior.

  • @jitxhere
    @jitxhere 11 місяців тому

    Amazing video

  • @francoortegadev
    @francoortegadev 11 місяців тому

    I don't think that I've come across this issue yet, and I still don't quite understand why the collapsing margin created whitespace, but I do appreciate the tips in case I do encounter this in the future. Also, I did see video about the whitespace issue with images, and that explanation did click for me.

  • @farzadbahadorifar1126
    @farzadbahadorifar1126 11 місяців тому

    another awesom video, in this short time, I really happy you start making these awesome videos and share it more and more, thanks a lot.

  • @codeVictor
    @codeVictor 11 місяців тому

    Thanks

  • @lachesis1033
    @lachesis1033 11 місяців тому

    I love your content, and i don't want you to stop creating.

  • @Nikhil-dp2mw
    @Nikhil-dp2mw 11 місяців тому

    nice