Web Site Design Method

Hey experts,

can anyone tell me how the following web page keeps the nav bar stuck to the top of the page when you scroll down?


What piece of code does this?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

probably position:fixed

jeffiepooAuthor Commented:
I don't think that would make sense because it isn't fixed to the top of the page until you scroll down. Otherwise it is below the top of the Bare Bonez label.
Hi Jeff,

There is two parts to the nav bar on that site.  The first is the use of "position:fixed;" and "top: -10px", that is the code that sticks the nav bar to the top of the screen.

There is also a javascript portion (in http://barebonesmusic.net/javascripts/magic-nav.js) that changes the CSS from "position: static" to "position: fixed" and vise versa depending on what portion of the page you are viewing.  For example, if you scroll all the way to the top of the page the position is static, allowing the nav bar to be in the middle of the page, when you scroll down so the nav bar would disappear the position is changed to fixed.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jeffiepooAuthor Commented:
Cool, thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.