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!
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

Norman Dubois
Courses Plus Student 1,767 PointsFixed navigation bar under a header section
Hi all,
i want a navigation bar for a single page website which is positioned under my header section. I want that, if i scroll down, my navigation will be fixed at the top of my browser window. But it should only be fixed if i scroll down. How could i handle this?
Thanks!:)

Andrew Stelmach
12,583 PointsGiving the nav element position: fixed; in your CSS should do it.
4 Answers

Mark Josephsen
8,803 PointsYou could do it like this:
<div class="footer">
<!-- footer content here -->
</div>
.footer {
position: fixed;
bottom: 0;
}

Logan R
22,989 PointsI have never personally done this, but I do know you need to use JavaScript or JQuery to accomplish this.
This might help you out with your problem: http://stackoverflow.com/a/6981076

Norman Dubois
Courses Plus Student 1,767 PointsCool, that's the solution! Thanks!! :) It's really cool and i will try it next week at work:)

Mark Josephsen
8,803 PointsHooray! If you don't mind, could you click "Best Answer" for me? It's worth a few points...
Thanks!

Norman Dubois
Courses Plus Student 1,767 PointsYes, it's a large site. That's because I need a navbar :)
Wayne Priestley
19,579 PointsWayne Priestley
19,579 PointsHi Norman, I'm just curious as to why you want a navbar for a single page site? Is it a very long page and you wish to be able to jump from section to section?