Lesson info

Webflow's navbar element is very flexible when it comes to styling. In this video, we're going to focus on five areas that give us that control:

  1. Size of the navbar
  2. Positioning of the navbar
  3. Nav link states
  4. Navbar and nav link backgrounds
  5. Nav link transitions

Assets

Want to follow along with this lesson? Fortunately, we created a zip file which contains all the assets used in the project, and we've included that link 

right here
.

Transcript

The Navbar element is very flexible when it comes to styling, and we're going to focus on five of the biggest areas that give us that control: size, positioning, typography, backgrounds, and transitions.

Let's start with size. Our Navbar's height is being determined by the content inside. That means if we select the Navbar itself, it has no preset values for width or height. We can constrict it horizontally by setting a width or by putting it inside a container, but when it sits inside our page Body, it's going to take up the full width.

Now in this example, we've already applied a class to each of these nav links. That means changes to that class affect all the nav links in the Navbar.

So, what's one way to adjust size? If we hold option, and click and drag to adjust our padding, we can see that the size of our Navbar adjusts accordingly. As we change our padding, the size of our nav links, and therefore all its parent elements, is changing with it. 

That's one way, but a more uniform approach might be to select the Navbar itself. If we adjust padding on that, again holding down option, we can control the height because we're creating extra space between the Navbar itself and the Container which has all our Navbar elements inside.

We can also make these changes in our Nav menu. If we look at the Tablet view, under our Element Settings Panel, we can open our menu and make changes inside. If we select our nav link over in our Element Style Panel, we can make similar adjustments. Holding option again to adjust the padding on the top and bottom at once. And we can see the size of the Nav Menu in this case is affected. This is really helpful for making sure that everything fits nicely, and that the size of your tap targets is large enough so finger taps on touch devices are intentional. And deliberate. And other synonyms.

That's size as it relates to the Navbar.

Next is positioning. By default, the position of the Navbar stays where you drop it. It takes up the full width because it’s display setting is set to Block by default. What if you want it to stay at the top of the page when you scroll? We can simply switch our positioning to fixed, using the top preset (to make sure our content takes up the full width of the viewport). And of course, the Navbar's position is persistent as we scroll.

And that's positioning as it relates to the Navbar.

Next we have typography. And a common styling change we can do here is on the nav links themselves. Now again, for this demo, we’ve gone in and added the same class to each of these, so we'll select one and make changes to that. And one of the simplest ways to visually indicate a hover is a color change on hover.

Under states, we can select hover, and choose a different font color here. We can go to white for now so we can observe the effect. And when we hover? Our font color now displays as white.

Next, let's talk about background.

With our Navbar selected, we have the same types of controls to modify background values. By default, we have an inoffensive gray background color.

We can set up a gradient on top of that. And we can set the colors for each of the stops in that gradient, and then once we've done that, we can tweak the positioning of each of the stops to achieve the look we want.

Of course we don't have to use a gradient; we can also simply set a background color right on our Navbar.

And of course, we can do the same thing with our nav links here on hover. Just like we did for text, we can go into the hover state, and set — for instance — a background color on hover. And when we do that, anything inside the boundary for our nav link will be affected on hover.

That's background.

Finally, let's talk transitions.

Right now, our text color and our background color immediately cut on hover. If we want to smooth that out so they fade or dissolve between those values, we can do that under transitions.

We'll go in and add two transitions: creating our first transition for font color. For now, we'll keep the default 200 millisecond value. And after that, we can add a second transition, this time affecting the change in our background color.

Once we're finished with that, we can hover over the nav links right on our canvas...and they transition smoothly.

And remember that one time? When we did that fixed Navbar? Sometimes you might want to add some transparency there. Simply choose a background color and drop the opacity a bit, and you'll get that precise effect.

So. By default, a Navbar's size is determined by the brand and the nav links inside. But you can set padding to make adjustments. The Navbar is a block element which pushes content down, but we can do fixed – if we want a fixed-position or persistent Navbar. We reviewed adjusting typography settings like nav link font color on hover. We adjusted the background on our Navbar; we changed the nav link backgrounds on hover. And of course we set transitions. We can smoothly transition from one state to another.

That’s...Navbar styling.