Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Fixed 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?


Wayne Priestley
Wayne Priestley
19,567 Points

Hi 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?

Giving the nav element position: fixed; in your CSS should do it.

4 Answers

Mark Josephsen
Mark Josephsen
8,803 Points

You could do it like this:

<div class="footer">
  <!-- footer content here -->
.footer {
  position: fixed;
  bottom: 0;
Logan R
Logan R
22,989 Points

I 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

Cool, that's the solution! Thanks!! :) It's really cool and i will try it next week at work:)

Mark Josephsen
Mark Josephsen
8,803 Points

Hooray! If you don't mind, could you click "Best Answer" for me? It's worth a few points...


Yes, it's a large site. That's because I need a navbar :)