24. A more complicated navigation - Responsive CSS Tutorial
Key Takeaways
Styles a navigation with a more complicated layout
Full Transcript
off so let's go and twe once you take this nice navigation we did and I think it already looks pretty good but we want to up the game of it a little bit and make it look like this which is quite common on sites that you see these days where we have the navigation on the right and probably a logo or something else on the left side and we can just keep going using what we know about flexbox to pull this off so let's go and take a look what I'm going to do is it will be a bit wider so I'm going to leave this at a large size like this just for now so it does mean we'll have to shrink and open it but that's okay so before we get into it what I want to take a look at is how I'm gonna structure it so we have already my header which has that light gray background on it and some padding on the top and the bottom then I have already this div for my site title and I have my nav over here that has my UL in it but I need something that's gonna hold all of my content in the middle of the page just to stop it from stretching from one extreme end to the other so for that you can probably guess the name of it already I'm gonna call that div class equals container and I can come all the way after my nav here and I can close that container and I'll put a comment here close container just so I can remember what that is if ever ice you know I'm not sure why I have this random div floating around and because all of this is nested inside of that container I'm gonna select it all and push tab on my keyboard and it will just push it all over so I can see through the nesting and through my spacing here that I'm inside of my container I'll jump back over to my stylesheet now and we can start styling this so I might a poorer fee I'm gonna come here to layout and the container is something very generic so here's my header I'm gonna put because it's more generic I'm gonna do this right at the top I'm gonna say container let's give it a width of let's say 90% because that's sort of what we've been doing and a max width and I'll stick with a I'm gonna 900 pixels for now we can always play with this a little bit later to make it bigger if we need to and just so we can really see it for now I'm gonna give it a border of one pixel solid madge and just like we've been doing up until now so there it is we just need it to be centered on the page now because we can see it is limiting to that max width and it is shrinking when we're going to the smaller sizes so I'm gonna let you Center it on the screen before I go ahead and do it I know I've had you do this one a lot but it is one of those things that people forget with the margin Auto on the left and the right especially early on when they're writing a lot of CSS they use a text align and it doesn't work and eventually they remember and it sort of cements in so I'm trying to cement it in as fast as I can by getting you to do it as often as possible so you can see here now that it is working and it's centering on the screen and because my max width it does limit it to the total size there but now we want to take this and put it on that side and take this and put it on this side we don't have the rest of our content and normally I would write all of my HTML first and then I would come through and write my CSS but we're not doing it this time just because we're focusing on just the navigation here so I wouldn't want to put a display flex on a container if that container is going to be reused in many places so like I've been talking about before I like having modifier classes I'm going to call it container nav and we can come back in and now I can edit that so on container I would come down right below that and add a container nav and give this a display of Flex if you did this ahead of time and you were just sort of jumping ahead because you wanted to practice and you thought you know and you gave it a different name or you put it directly on the container or whatever that divs that you gave it that's completely fine or if you just had some sort of like nav box and you put all of these styles on it it's okay I just know I'm gonna be reusing the width the max width and my margin:0 auto a few times on this site so I figure having a default container that I can reuse multiple times makes a lot of sense and then if I need to change it I can so display a flex it makes our columns if we come and take a look there we go we have two columns now now there are a few things that we want to change the easy one to fix is this is getting centered in here and we don't want anything to be centered that was in my heading header header text align Center which we don't need to have anymore so we can remove that and at least it will fix that problem and this part is perfectly fine but I want to move these all the way over to the right side can you think of a way we can do that that we've already looked at so if you remember this pink box here is my container and it's also my container and have and on the container nav I did display flex and they have all this empty space left over on this side and how can we redistribute empty space to put it in between things we can use justify content space between so justify content space between and there's only two items in this case so it just means all that empty space gets put here in the middle there's one last thing as you can see there is a bit of a gap here and you might be hanging that's not a big deal and my probably isn't the end of the world but because I know I'm going to be using a container and other content here and I want things to line up really nicely little differences like this make the difference between someone who's a good coder or a good designer and someone who's a little bit sloppy and people who are hiring are paying attention to details so you do need to learn how to be detail-oriented and look for these little things where things aren't lining up it's not as obvious when you don't have a border on something but you'd still notice that it's not perfectly lined up so if you remember what I did when I created this because it was Center aligned I said we can do a margin on the left and the right side and everything would be fine because it's centered and that means it's Eve they'll be equal margins on the left and the right which will keep it centered now we have it on the right side so that means I only want my margins on the left this is one of the few times when I won't use the shorthand and I'll just say margin left and in this case I'll do 2m and we can take a look and now we've gotten rid of that space but I've kept everything here I did 2m instead of one because before I had one M on home and one M on about me here so one plus one I was getting two on the side and I was getting two on this side here as well where's now I'm only putting a march on the left so I'm putting it as two M that does mean there's a two M margin on this side here but that's fine that's not getting in the way of anything it's just giving us a little bit of breathing room and if anything it's gonna stop us when we're shrinking from hitting that the the social life text that's right there so it's gonna prevent us from smacking into that and that gives us the room that we need now it's starting to look pretty ugly when I do this though so the first thing I'm going to do right now is I'm going to turn off this border of magenta because we don't want that on there anymore which makes it look a little bit better and in the next video we're going to add in a media query to prevent this weirdness from happening and we're gonna add it so this actually falls underneath and we have a few different changes going on we'll get some practice with mediocre
Original Description
🎓 View our courses: https://scrimba.com/links/all-courses
This tutorial is a part of "The Responsive Web Design Bootcamp" on Scrimba. Explore the full course here: https://rebrand.ly/responsivebootcamp_yt
For such a simple and small part of a website (though a very important part of one), navigations, and the header in general, sure do take a lot of styling to get to look good!
In this case, we need to add in a .container to hold the content in the center of the page, and then make a few changes to it to get the two columns required for this layout.
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Scrimba · Scrimba · 33 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
▶
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
CSS Grid Course: Learn the Basics in 3 Minutes
Scrimba
CSS Grid Course: Positioning Items
Scrimba
CSS Grid Course: Why Learn It And How It Compares To Bootstrap
Scrimba
CSS Grid Course: auto-fit & minmax
Scrimba
CSS Grid Course: Implicit Rows
Scrimba
CSS Grid Course: Fraction Units And Repeat
Scrimba
CSS Grid Course: Justify Items and Align Items
Scrimba
CSS Grid Course: An Awesome Image Grid
Scrimba
CSS Grid Course: Named Lines
Scrimba
CSS Grid Course: auto-fit vs auto-fill
Scrimba
CSS Grid Course: Justify Content and Align Content
Scrimba
CSS Grid Course: Template areas
Scrimba
27. Setting up the structure - Responsive CSS Tutorial
Scrimba
25. Making the navigation responsive - Responsive CSS Tutorial
Scrimba
36. Playing with the title's position and negative margins - Responsive CSS Tutorial
Scrimba
31. Starting the CSS for our page - Responsive CSS Tutorial
Scrimba
26. Taking a look at the rest of the project - Responsive CSS Tutorial
Scrimba
15. Spacing out the columns - Responsive CSS Tutorial
Scrimba
33. Starting to think mobile first - Responsive CSS Tutorial
Scrimba
22. Making our navigation look good - Responsive CSS Tutorial
Scrimba
37. Changing image size with object-fit - Responsive CSS Tutorial
Scrimba
44. Module Wrap up - Responsive CSS Tutorial
Scrimba
16. Controlling the vertical position of flex items - Responsive CSS Tutorial
Scrimba
39. Setting up the widgets and talking breakpoints - Responsive CSS Tutorial
Scrimba
42. Setting up the About Me page - Responsive CSS Tutorial
Scrimba
35. Changing the visual order with flexbox - Responsive CSS Tutorial
Scrimba
23. Adding the underline - Responsive CSS Tutorial
Scrimba
21. Using flexbox to start styling our navigation - Responsive CSS Tutorial
Scrimba
20. Creating a navigation - Responsive CSS Tutorial
Scrimba
40. Using a new pseudo class to wrap up the homepage - Responsive CSS Tutorial
Scrimba
43. Fixing up some loose ends - Responsive CSS Tutorial
Scrimba
32. Starting the layout. Looking at the big picture - Responsive CSS Tutorial
Scrimba
24. A more complicated navigation - Responsive CSS Tutorial
Scrimba
28. Feature article structure - Responsive CSS Tutorial
Scrimba
34. Styling the featured article - Responsive CSS Tutorial
Scrimba
18. Making layout responsive with flex direction - Responsive CSS Tutorial
Scrimba
19. flex direction explained - Responsive CSS Tutorial
Scrimba
41. Creating the recent posts page - Responsive CSS Tutorial
Scrimba
17. Media Query basics - Responsive CSS Tutorial
Scrimba
30. Home Page. HTML for the aside - Responsive CSS Tutorial
Scrimba
38. Styling recent articles for large screens - Responsive CSS Tutorial
Scrimba
29. The home page. HTML for the recent articles - Responsive CSS Tutorial
Scrimba
10. ems and rems an example - Responsive CSS Tutorial
Scrimba
1. Starting to think responsively - Responsive CSS Tutorial
Scrimba
4. Controlling the width of images - Responsive CSS Tutorial
Scrimba
5. min width and max width - Responsive CSS Tutorial
Scrimba
3 CSS Units. Percentage - Responsive CSS Tutorial
Scrimba
11. Flexbox refresher and setting up some HTML - Responsive CSS Tutorial
Scrimba
12. Basic Styles and setting up the columns - Responsive CSS Tutorial
Scrimba
8. The Solution Rems - Responsive CSS Tutorial
Scrimba
14. Setting the columns widths - Responsive CSS Tutorial
Scrimba
2 CSS Units - Responsive CSS Tutorial
Scrimba
7. The problem with ems - Responsive CSS Tutorial
Scrimba
6. CSS Units. The em unit - Responsive CSS Tutorial
Scrimba
13. Adding the background color - Responsive CSS Tutorial
Scrimba
9. Picking which unit to use - Responsive CSS Tutorial
Scrimba
Tutorial to Learn Alpine JS - Full Course for Beginners
Scrimba
Guide To Algorithms in Javascript [Binary Search] - Full Course / Tutorial
Scrimba
Learn UI Design [7 Fundamentals Tutorial] - Full Course for Beginners
Scrimba
Javascript Tutorial for Beginners [From 0 to ES6+] - Full Course
Scrimba
Related AI Lessons
⚡
⚡
⚡
⚡
You’re Still Paying $200/Month for AI Tools You Could Replace With a Free Local Setup Tonight
Medium · Data Science
Top 10 AI Tools Every College Student Should Know in 2026
Medium · AI
The Future of Technical Education: AI, Projects, and Industry Collaboration
Dev.to AI
I Asked Gemini AI to Preview My Haircut Before My Salon Appointment - Here’s What Happened
Medium · AI
🎓
Tutor Explanation
DeepCamp AI