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 trialJordan C
6,249 PointsWhy doesn't putting auto top-margin on the footer work?
Here is my code:
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
footer {
margin-top: auto;
}
1 Answer
janatoc
14,884 PointsHi, I had the same issue. It's because footer has the margin already set in the base.css file --> .main-footer {margin-top: 30px; } As class selector (.main-footer) has higher specificity than element selector (footer), it will overrule your footer {margin-top: auto;} style. You have to set .main-footer {margin-top: auto;} that should work.
Y B
14,136 Pointsperfect thanks, I did exactly the same thing, I couldn't see why it didn't work.
Antonio English
Front End Web Development Techdegree Graduate 18,103 PointsAntonio English
Front End Web Development Techdegree Graduate 18,103 PointsThe spec says so. 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements
If 'margin-top', or 'margin-bottom' are 'auto', their used value is 0.
https://www.w3.org/TR/CSS2/visudet.html#Computing_heights_and_margins