Sticky navigationÂ
What we want to do is make the navigation stick to the top when we scroll passed the Blog
section, as shown in the following screenshot:Â
The sticky navigation we want to build.
To make this happen, we'll add an extra class with jQuery on the header. This extra class will make the navigation stick to the top and make the navigation background dark. Let's first create this extra class:Â
header.sticky { }
Note
We need to be careful here as we didn't separate the class with space, which means it's when the header has also the class sticky
.Â
To this class, we will add the following properties:Â
header.sticky { position: fixed; top: 0; background-color: #212121; background-image: none; }
Let's break that down:Â
- We useÂ
position:Â fixed;
as we want to make the navigation stick to the top.position: fixed
will position the element relative to the browser window. top: 0;
 tells us it will stick to the top.Âbackground-color:
 sets a solid background color.background-image: none;
 removes...