
Jasper Kop
9,057 Pointswhy is the auto top margin moving the button down?
I wonder why the auto top margin is moving the button down?
when I was thinking about the question van Gail I had some idea's but after trying them it didn't work out of course, but I don't understand the auto top margin why it works
2 Answers

Jim Camomile
350 PointsHi 2pd, The key to your question is that the item, in this case the button, needs to be a (flex item), then when you apply margin-top: auto; to your button it will take up all the (space available) around itself therefore pushing the item to the bottom of the box, just like you would use margin-left: auto; and margin-right: auto; it centers the item, but if you take away margin-left: auto; the item will move all the way to the left of the container it's in, I recommend watching the video again, also try using the code in different scenarios to understand it better.
Happy coding, Cheers!

Samet Erpik
1,187 PointsYou can set the margin property to auto to horizontally center the element within its container.

2pd
7,147 PointsHow does your comment explain why the buttons move to the bottom of the container?
Carlos Saborio
5,387 PointsCarlos Saborio
5,387 PointsThanks for the answer Jim!