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

Footer trouble

Hi,

I'm trying to get my footer to stay at the bottom of the page without over lapping the other elements when the screen is shrunk down. I can't seem to get my code to accomplish both of my needs. Could help me out? This has been a problematic issue for me!

Thanks,

Jason

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Square Water Proofing</title>
        <link rel="stylesheet" href="css/main.css">
        <link href='https://fonts.googleapis.com/css?family=Libre+Baskerville' rel='stylesheet' type='text/css'>
    </head>
    <body>
    <div id="container">
        <header>
            <a href="index.html" id="logo" class="title">
                <h1>Square Water Proofing</h1>
            </a>
            <nav>
                <ul>
                    <li><a href="our_story.html" class="nav-key">Our Story</a></li>
                    <li><a href="services.html" class="nav-key">Services</a></li>
                    <li><a href="beforeafter.html" class="nav-key">Before & After</a></li>
                    <li><a href="contact.html" class="nav-key">Contact Us</a></li>
                </ul>
                <section class="call-us">
                <h2>Call us today!<a href=tel="617-416-9403" class="tel">(617) 416-9403</a></h2>
                </section>
            </nav>
        </header>    

        <section>
            <banner>
                <img src="" class="banner-image">
            </banner>
        </section>
        <section>
            <h2>About Us</h2>
            <p>Something something something about us</p>
        </section>
        <section>
            <ul id="main-services">
                <li><a src=""></a></li>
                <li><a src=""></a></li>
                <li><a src=""></a></li>
            </ul>
        </section>
        </div>
        <div id="socialmedia">
            <footer id="footer">
                <a href="facebook.com"><img src="images/facebook.png" alt="Facbook" class="socialmedia"></a>
                <a href="instagram.com"><img src="images/instagram.png" alt="Instagram" class="socialmedia"></a>
                <h4><a href="http://jasonladieu.com" id="copyright">&copy; 2016 Jason Ladieu</a></h4>
            </footer>
        </div>

    </body>
</html>
/**********************
***Footer***********/

footer {
    clear: both;
    margin:0;
    margin-top: 50%;
    height: 80px;
    text-align: center;
}

.socialmedia {
    display: inline-block;
}




#copyright {   
    font-size: 10px;

}

#copyright:link {
    color: silver;
}

#copyright:visited {
       color: silver; 
}

#copyright:hover {
    color: black;
}

1 Answer

You could try something like this

This will set your container height to 100% of view height minus the height of the socialmedia div. Which should give the effect of the footer being stuck to bottom of the page when there isnt enough content to naturally fill your page.

#container {
  min-height: calc(100vh - 100px) /*You can swap in the 100px value for something more appropriate for the footer height*/
}

#socialmedia {
  height: 100px; /*again this can always be swapped for a more suitable height if you prefer */
}

Hope this helps.

Happy coding!