Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMark Lawson
6,148 Pointsmargin-top
Around 1:30 into the video, he adds a margin-top: 15px to the code; however, it does not move anything. I have to add quite a lot of margin-top to the CSS, this then forces both the logo and the main-nav to shift down. My question is; does the top-margin actually work in this situation??
.main-nav li { margin-top: 15px; margin-right: 10px; }
Thanks
1 Answer
Steven Parker
231,198 PointsThis is called margin collapse. When there's nothing intervening (like a border or padding) the vertical margins of a parent and child element are combined, and only the larger one takes effect. The same thing happens between an element and its siblings when they are stacked vertically.
Unordered lists have vertical margins by default, so you won't see any change until you set a margin on the child LI that is larger than the default of the UL.
And no, it doesn't look like the margin set on the LI's in the video is large enough to do anything!