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 trialEmily Nkosi
915 PointsNeed Help with a Nav Float
Hi, my nav will not stay in it's container. Can anyone see why?
<div class="container clearfix">
<a href="/" title="Come Back Home" id"logo" >
<img src="/Users/ashleynkosi/Desktop/P2h/Images/CAmherstLongLogo.png" alt="our logo the pretty hummingbird" width="30%" hieght="15%">
</a>
<nav>
<ul>
<li> <a href=""> About </a> </li>
<li> <a href=""> Services </a> </li>
<li> <a href=""> Portfolio </a> </li>
</ul>
</nav>
</div><!-- end container -->
THANK YOU SO MUCH!
7 Answers
Emily Nkosi
915 PointsAnd here's some of my CSS...
.container {
width: 940px;
padding: 0 10px;
margin: 0 auto;
}
.clearfix:before
.clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
zoom: 1;
}
Matt West
14,545 PointsHi Emily,
I can't be sure without seeing the rest of your CSS but try adding the clearfix
class to the <ul>
element.
If that doesn't do the job, please post your code to something like codepen and I'll take a look at it for you :)
Matt
Kevin Korte
28,148 PointsIs there an opening div container class that you forgot to add into your example, because as it stands there is no container div there, that I saw.
Also, in your anchor id you forgot to put the = sign between id and "logo".
Emily Nkosi
915 PointsOk thank you both, here's a link to my code. I will check those things but I would love it if you took a look.
http://codepen.io/emilyknkosi/full/ydptH
Thanks!
Matt West
14,545 PointsAdding the clearfix
class to the <nav>
element should do the job.
Here's an adapted codepen: http://cdpn.io/kLpIB
Emily Nkosi
915 PointsThanks Matt!
Emily Nkosi
915 PointsThanks Matt!