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 Page Layout with the Float Property Footer Layout with Floats

floats inside the <footer>, made the height to collapse.How do i di it?

As the topic suggest, i am unable to pass it. What i did was

footer{
  overflow:hidden;
}

or

footer{
 clear:both;
}

but i am unable to pass it.

style.css
/* Complete the challenge by writing CSS below */
.footer-nav{
  float:left;
}
.logo{
  float:right;
}
.footer-nav li{
  float:left;
}
footer{
  overflow:hidden;
}
.clearfix::after {
  content: "";
  display: table;
  clear: both;
}
index.html
<!DOCTYPE html>
<html>
<head>
    <title>Getting Started with CSS Layout</title>
    <link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
    <body>
    <div class="container">
        <footer>
            <img class="logo" src="city-logo.svg" alt="logo">
            <ul class="footer-nav">
                <li><a href="#">Ice cream</a></li>
                <li><a href="#">Donuts</a></li>
                <li><a href="#">Tea</a></li>
                <li><a href="#">Coffee</a></li>
            </ul>
            <p class="copyright">&copy;2015 The Best City.</p>
        </footer>
    </div>
    </body>
</html>

4 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

These are the instructions from the step 3 of the challenge. "The floats inside the <footer> caused its height to collapse. Give the <footer> element the class that will clear all floats inside it." What it wants you to do here is simply add the class "clearfix" to the footer element. That is done in index.html . Take a look at this line:

<footer class="clearfix">

This is what the challenge is looking for.

Juan Di Diego
Juan Di Diego
3,265 Points

haha JEN!!!!!!!!! You beat me! I was just posting to this question and when I clicked "Post comment" your comment appeared! :P

You select the footer and do clear: both;. This property causes the footer to push floated element out of the way, and thus ignore problems like overlap and height collapsing.

Juan Di Diego
Juan Di Diego
3,265 Points

I see that you have a class in your css called ".clearfix", but you aren't using it in your HMLT. You should apply that class to your footer tag and that should solve your issue. overflow:hidden; should also work, but then you run the risk of other elements being cut off if the are positions absolute in the box in the future.

Try doing this:

<footer class="clearfix">

Good luck!

You select the footer and do clear: both;. This property causes the footer to push floated element out of the way, and thus ignore problems like overlap and height collapsing.