How to Create Navigation on Scroll

Alexandra Mladenovic
HackerNoon.com
3 min readJul 24, 2018

--

A challenge Kolosek team recently faced was that we needed to create a navigation that shows only when scrolling up.

How did we solve it?

Well, firstly, the HTML for the form was created. Keep in mind that while creating the form, Bootstrap was used. Here we have solved the problem using CSS and jQuery.

Some of the useful CSS properties that should be learned are relative font size, columns, relative and absolute positioning. Now, let’s move on.

Then, we created the static navigation and the navigation that should appear on scroll up.

We created two identical navigations, one beneath the other. The difference was: one should appear when scrolling up and have a different background, while the other should remain static at the top of the page.

In order to do this, these navigations had to have different identifiers.

The navigation that appears on scroll had a class “.navigation-bar-scroll”, while the static navigation had a class with a different name so that the styles won’t get mixed.

We used the following SCSS for the navigation that appears on the scroll:

Then, we used the following JQuery code to implement the “show on scroll up” functionality.

We have achieved the effect of a navigation appearing when scrolling up. This navigation bar will disappear when the scrolling reaches the top, while the second static navigation will be located at the top of the page. Looks pretty cool, doesn’t it?

Here’s our final tip: navigations should be identical so users don’t get confused. The only difference you can add is a different background color for the navigation that appears on scroll up, so the links of the navigation stay clearly visible on the page with a lot of content.

This is just one of the many ways you could improve the design of your website.

Hope you found this short blog post helpful!

Thank you for reading! :)

Originally published at kolosek.com on July 24, 2018.

--

--