Fireship · @fireship
Animated Responsive Navbar with CSS - Plus Other Useful Tricks
Uploaded February 28, 2020 · Length 11:40
Summary
Build a responsive navigation menu from scratch using plain CSS, including Flexbox, transitions, and media queries.
- responsive navbar
- css from scratch
- flexbox
- css transitions
- media queries
- css layout
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
You don't need Bootstrap, and you definitely don't need to pay for an expensive theme to
- 0:03
add a beautiful navigation layout to your web app.
- 0:06
Today we'll build a responsive navigation menu from scratch using nothing but plain
- 0:10
CSS.
- 0:11
You'll learn how to use Flexbox to position things, transitions to animate things, and
- 0:14
media queries to make things responsive.
- 0:16
And I'll throw in a bunch of other small tricks like duotone icons, transforms, filters,
- 0:20
and more.
- 0:21
If you're new here, make sure to subscribe, and if you want to see more project-focused
- 0:25
videos like this, make sure to hit the like button and leave me a comment below.
- 0:28
Let's start by taking a closer look at what we're actually building.
- 0:31
We have a navigation bar that's fixed to the left side, taking up the full height of
- 0:35
the viewport.
- 0:36
If you hover over it, it animates out, showing text for each individual item.
- 0:40
And notice how the arrow at the top rotates in and out of place depending on the hover
- 0:43
state.
- 0:44
Now hovering over an individual item will animate the background color as well as the colors
- 0:48
in the SVG icon itself, which gives you a subtle but also very cool looking duotone effect.
- 0:54
Now we'll be using Flexbox to lay everything out, which makes it really easy to convert
- 0:58
a column into a row.
- 1:00
So we'll use a media query for small devices to take the navbar and fix it to the bottom.
- 1:05
And that should provide a much better experience on mobile, assuming that your app is intended
- 1:08
to be used in portrait mode.
- 1:10
That gives us a good starting point, so let's go ahead and jump right into the code.
- 1:13
Now this video is designed for you to follow along, but we'll be moving at a very quick
- 1:17
pace, so feel free to slow down the playback speed or pause if necessary.
- 1:21
You'll notice I have an index.html file, and a style.css file which is referenced in
- 1:26
the head of that HTML document.
- 1:28
And you'll also notice I have a custom font from Google Fonts, feel free to use whatever
- 1:32
font you prefer.
- 1:33
Now moving on to the body of the HTML, we have a nav element, which is the main thing
- 1:37
we're building today.
- 1:38
Then alongside that, we have a main element to hold the main content of the page, and
- 1:42
right now it's just filled up with a bunch of hipster ipsum.
- 1:45
Currently, our HTML is completely unstyled.
- 1:48
Let's start by setting a few values we can reuse throughout our CSS on the root pseudo
- 1:52
class selector.
- 1:54
We can set the font size here, and we'll also define a few custom properties, aka variables,
- 1:59
that represent the theme of the application.


