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 trial

CSS CSS Layout Basics Getting Started with CSS Layout Creating a Sticky Footer

my footer dont stick to the bottom of my page

my code

/* ================================= Base Element Styles ==================================== */

  • { box-sizing: border-box; }

body { line-height: 1.6; color: #3a3a3a; }

p:last-child { margin-bottom: 0; }

a { color: #fff; text-decoration: none; }

/* ================================= Base Layout Styles ==================================== */

/* ---- Navigation ---- */

.name { margin: 0; }

/* ---- Layout Containers ---- */

.container { padding-left: 1em; padding-right: 1em; }

.main-header { padding: 1.5em 0; background: #3acec2; }

.main-footer { text-align: center; padding: 2em 0; background: #d9e4ea; }

/* ================================= Media Queries ==================================== */

@media (min-width: 769px) {

.wrap { min-height: calc (100vh - 89px); }

.container { width: 70%; max-width: 1000px; margin: 0 auto; } }

3 Answers

John Coolidge
John Coolidge
12,614 Points

I can't see your HTML markup, but did you wrap your header and main container inside a div with the class .wrap? Recheck your HTML markup to make sure you didn't accidently misplace a element's tag.

Simply add following CSS properties to your main footer class (.main-footer)

For example:

<div class="main-footer">
<!-- Your Footer content here -->
</div>
.my_footer{
 text-align: center; 
padding: 2em 0; 
background: #d9e4ea; 
padding:10px;
position: fixed;
bottom:0;
z-index:9999;
}

Go to your html and in the <div> that he had you create above the <header> add the class="wrap" and once you do that it'll connect with your css and you'll be able to see the change in your browser.

Make sure your css is .wrap{ min-height: 100vh; }