Course contents
SECTION: 4
Project 2: Bike Repair Website 6:12:48
SECTION: 6
Project 4: Bootstrap Yogurt Website 3:35:39

Questions

1
You are not following this thread
1
You are not following this thread
1
You are not following this thread
1
You are not following this thread
1
You are not following this thread
1
You are not following this thread
1
You are not following this thread
0
You are not following this thread
0
You are not following this thread
0
You are not following this thread
0
You are not following this thread
1
You are not following this thread
0
You are not following this thread
1
You are not following this thread
0
You are not following this thread
0
You are not following this thread
0
You are not following this thread
0
You are not following this thread
0
You are not following this thread
0
You are not following this thread

Course info

128 lessons / 17 hours 5 projects Certificate of achievement

Overview

Hi there, my name is Daniel Scott and together we’re going to learn how to build professional responsive websites. which look good on mobiles, tablets and desktop screens.

We will build 4 sites together...
  • a simple but elegant restaurant website.
  • a bike repair website. 
  • a responsive portfolio website.
  • a Bootstrap website.  

We cover everything you need to build your first website. From creating your first page through to uploading your website to the internet. We’ll use the world’s most popular (and free) web design tool called Visual Studio Code.

There are exercise files you can download and then work along with me. At the end of each video I have a downloadable version of where we are in the process so that you can compare your project with mine. This will enable you to see easily where you might have a problem.

We will delve into all the good stuff such as how to create your very own mobile burger menu from scratch learning some basic JavaScript and jQuery. 

 You will...
  • Learn how to work with responsive images and icons. and stunning full screen background images and probably one too many gradients. 
  • Learn how to create forms and to choose great fonts for your website. 
  • Learn how to work with Bootstrap 4 to easily add carousels, cards and complex looking menus. 
  • Setup a domain name with hosting so that your website is live on the internet for others to see.  

There are fun class projects for you to work on which will enable you to practice what you learn. By the end of this course you’ll have a great understanding of important web design topics like HTML5, CSS3, Flex box, Responsive design and Bootstrap.   

If that all sounds a little too fancy - don’t worry, this course is aimed at people new to web design and who have never coded before. We’ll start right at the beginning and work our way through step by step. 

Who am I? 

I’m Dan, and I’ve been building websites for about 15 years now. I am award winning instructor, and have won a MAX Master award for the last 2 years in a row at the prestigious Adobe Max conference.

Time to upgrade yourself?
Sign up for the course and let’s learn how to build responsive websites.

Course duration 16 hours 42 mins
Daniel Walter Scott

Daniel Walter Scott

Founder of Bring Your Own Laptop & Chief Instructor

I discovered the world of design as an art student when I stumbled upon a lab full of green & blue iMac G3’s. My initial curiosity around using the computer to create ‘art’ developed into a full-blown passion, eventually leading me to become a digital designer and founder of Bring Your Own Laptop.

Sharing and teaching are a huge part of who I am. As a certified Adobe instructor, I've had the honor of winning multiple Adobe teaching awards at their annual MAX conference. I see Bring Your Own Laptop as the supportive community I wished for when I was first starting out and intimidated by design. Through teaching, I hope to bring others along for the ride and empower my students to bring their stories, labors of love, and art into the world.

True to my Kiwi roots, I've lived in many places, and currently, I reside in Ireland with my wife and kids.

Certificates

We’re awarding certificates for this course!

Check out the How to earn your certificate video for instructions on how to earn yours and click the available certificate levels below for more information.

How to earn your certificate

Work your way towards your certificate for this course by following these simple steps.

  • Watch the course videos
  • Complete the Class Projects - look out for the videos marked with
  • Upload your class projects into the My Projects area in your account
  • Complete and pass the Knowledge Quiz (Merit level courses only)
  • Complete the Distinction Certificate Project (Distinction level courses only) - look out for the video marked with
  • Upload your Distinction project to the My Projects area in your account
  • Request your certificate when you've completed the requirements for the certificate level you're working towards

Good luck!

Pass certificates

We're awarding 'Pass' level certificates for this course.

You can work your way towards your 'Pass' certificate by following these simple steps.

  • Watch the course videos
  • Complete the Class Projects - look out for the videos marked with
  • Upload your class projects into the My Projects area in your account
  • Don't forget to request your certificate when all your projects are complete

Good luck!

Downloads & Exercise files

Transcript

Hi there, this video we are going to implement our really simple Mobile Nav, that we built in a last video, into our full site, where it goes from this to Desktop, to Mobile, with a sweet little drop-down. Now we kept this one separate, so that we could really kind of focus on implementing jQuery, but now we're going to fold it into our largest site. And, like this site here, this is what we currently got, we've got Buttons, and what we do is adjust the spacing on Tablet and Mobile, and I like this because it's going to really show us, what ends up happening in the real world, when you are trying to implement stuff, and it's never this simple, where you've just got this clean clear. You've got to do battle with existing bits of code, like in our case we've got this weird little drop-down thing here. We're going to have to unpick that to try and make this work. It's more of a real-world practical example, of the things that you might run into when you are trying to implement it. It's a really long intro, Dan, let's get started. 

So we're going to open up our existing site. I'm going to open up index.html, double-clicking it, open up style.css. Drag style over here, and let's get started. So first thing I want to do is, we're going to turn, let's turn Nav off when it gets to the Tablet screen. My mock-up, I've decided to go to this Mobile menu even at Tablet, so it's going to be on for both of these. So let's go and turn what we currently have off, and actually let's preview it, what have we got? It appears on the wrong page. So it gets down to here and it switches out. That's what we did previously, right? That is definitely an easy way to do it. We're going to do it with our JavaScript now. 

So what I want to do is, instead of flicking around, I want to just turn all those buttons off. We're going to turn our Mobile version on. So in VS code we are going to find our Nav. So this Nav here is going to turn off when it gets to Tablet. So I go to Tablet view. I'm going to double check I don't have anything else. Trying to control Nav, this here, no, so I'm just going to say, just above here I'm going to say, Nav, when you get to Tablet mode, display none. Now you are like, "Hey, what about this one?" Like we did all that styling in the last kind of few videos, to make it do all that kind of weird display changes for mobile. So this thing here is redundant, there's lots of stuff that is redundant, and I'm kind of half leaving this in the course, because it's not as easy, it's never as easy as like just, doing what I did in that first video, and just kind of adding it in. There's always like, "Ah, this bit controls it all, this bit's messing with it". So this one's going to be a little bit messy, but for good reason, so we can learn how to fix it. 

All right, so we're going to ignore all that. Let's just make sure it actually turns off, for, ready? Here you go. So when it gets down to Tablet mode, and down to Mobile, it turns off. So what we want to do now is have something else turn on, a little stripy line. So let's go back to VS code. So underneath Nav what we'll do is we'll create another Div tag, and we'll call this one dot, '.', let's call this one mob-wrapper. We're going to put everything inside of this. So inside my mob wrapper we're going to add our icon, of those little three stripy lines for our Mobile Nav, plus another set of these. So let's cheat, let's grab our image, so open up jQuery Nav, and this is the chunk we want. That's the icon that we brought in, the image, in SVG. We add a small text, we added a width, and we gave it a Class of Burger menu. So we're just going to cheat, because we're like, "Already done that." So we've got him in, just happens to be the wrong-- there we go, nice. 

Let's just check he actually appears, clean it all up. There he is. He's on the page but I want to turn him off, because he's appearing all the time. I only want him to appear when we get down to Mobile. So what we do is we, we've got three kind of parts. Remember, Global - then we - which is in our case, Desktop, then we get down to Tablet view, then we've got Mobile view, and because we're turning him on for-- we'll turn him on in Tablet. So let's find the bottom of here, remember, avoid the last curly brace. The whole Media Class is all wrapped up in opening curly brace, and it closes all the way down here. So always have two at the end, if you don't, things will go wrong. 

So we're going to say-- who do we want? .mob wrapper, I would like you, my friend, and everything inside of you to turn, actually we don't want to do anything for him yet. I want to cut him out and I want him in Desktop view to turn off. So just before the closing or opening of the Tablet, I'm going to say, mob wrapper, you are a display of none, please. So he's off on Desktop, which is perfect, but he never turns back on. So now we need to say, so he's off on Desktop, and then as it goes through, it's going to say, on Tablet though, I'd like to turn him on. So down the bottom here, before our curly brace, we're going to say, display:block. He's back on. So off on Desktop, and then on, on Mobile, or at least Tablet in this case, and because we don't say turn off again, it just flows through to Mobile. So we don't have to say that again in Mobile. 

Next thing is I want all the bits off the side, that we're going to turn off. Remember, all the buttons that are going to drop off, that we want activated by this little click. So what we need is-- we could just go and steal all of this. So all these buttons here, actually we'll grab every-- no, we'll grab these buttons, so there's my image, underneath my image, before our wrapper closes, so there's my wrapper, ends there. Just after the image I'm going to put in these guys. These guys need to be in their own Div tag. Why? Because they're kind of just floating around a bit. At the moment they've got no kind of-- no grouping, this guy's by himself, these guys, these three guys need to be tied together. So 'Command-Shift-P', 'Ctrl-Shift-P', start typing wrap, and we're going to use wrap with abbreviation. I'm going to wrap them up in something called, something I'm going to make up right now called, mob nav. Nav, come on, Dan. Can't see the keys, all right, mob nav. And it has to have a period in front of it. 

So wrap with abbreviation, .mob nav. Nice. So these guys here, let's have a little look. They should be off on Desktop, because they're all wrapped up in this thing, called mob wrapper, that we're turning on and off. If you still see them it means you've probably got these guys, after this closing Div, it needs to be inside. Nice. So, off on Desktop, and Tablet, they both turn on. The structure is all weird, we'll fix that for the last thing. What we want to do is just get this thing to click on and off first. So let's turn it off by default. So this little mob nav, that's why it's good in a wrapper, because we didn't, all off on one little go. So I'm going to say, on Tablet view, mob nav, .mob nav I would like you to just be off, display:none. Can't see them, I'd like to turn them on with JavaScript, when this thing is clicked. 

So to implement our JavaScript, or our jQuery in this case, we need to do two things, remember, we need to load the library, which is the kind of all the rules around JavaScript or jQuery, and then we need to actually put it on Custom Coding. So just like we did before, we're going to go to our Exercise Files. In your Exercise Files, there is Project3, there's one in here called jQuery Mobile Nav. Open that up, and that's the CDN, that is linking the library to tell our browser how this all works. And remember where we put it, we can put it up here in the Head, but it's more common to put it down here in the Body. We talked about the reasons why before. 

One of the things that happens is, like when I paste it, can you see, my file turns green up here, and a bunch of errors appear down the bottom here. It's because we're using a helper little extension, to give us kind of error checking for HTML, and it just doesn't recognize this. It's totally fine and legitimate. It's looking for a closing angle bracket after the script, but we're kind of implementing it slightly differently, and it works just fine, so we're just going to have to ignore that. So the extensions are great, they're built by other people. It's a bug in this particular one. Will this person who runs this extension go and fix it? Mike? I'm not sure. Maybe it's something that can't be fixed because of, he just needs to check for these different things. 

So I guess there's just-- a couple of things, one is, you'll see it go green in here, and it has three errors, which you should go and check. In our case, in my case this is working just fine. So we loaded the library, now we want to load the custom JavaScript. So we're going to create our own file, 'File', 'New File'. I'm going to save it, I'm going to call this one Scripts. scripts.js And I'm going to paste in my text. This is what we typed out in the last one, we're not going to do it again. The things you will have to work out is, I don't like this Slide toggle, going to get rid of the toggle. You'll notice that the toggle by itself is not upper case, it's Camel case. So the first one is always lower, and the middle ones are upper case. 

The other thing I want to do is make sure that these match up. So remember, when the document is loaded, I would like you to look for a click on, this thing, this Class called Burger menu, which in our case is going to be that little stripy icon, and when it does see that click on the stripy icon, toggle the Mobile Nav. So you need to make sure this and this match up. So let's do, let's add it first and then make sure they match up. So in index.HTML we're going to load our script. So we're going to go to Script Source. You're going to get a bunch more errors, and we're going to say, it is sitting in-- it's just called Scripts. scripts.js, there it is. That's all we need to do, so it's loaded. 

Next thing I want to do is make sure that this Burger menu matches up, with the wrapper that I've got. I mean, the Class that I've got applied to my icons. Here's my icon, and I'll apply that Class called Burger menu. Perfect. So that matches that. Next one is called Mobile Nav. So I want to turn this on and off. I haven't called it mob nav, I've called it mobile nav. So I've mixed up the name. So it's got to make sure that mob nav is in here. This is going to toggle that Div tag on and off. All right, let's see if it works. I have high hopes, let's go. Where are we? Here we are, toggle. So it turns it on and off, the layers all broken, but it's okay, the mechanics work, and that's what, I guess, most important for now. 

Now the reason this is happening, if you're following along with me exactly in this course, you probably have the same problem, you might not. You might-- because I want this guy up next to it, and it kind of is in this implementation. Can you see, these guys are stacked next to each other, but when they're down they kind of fall apart. So the only reason they're doing that is because, I figured that out, and I'll show you my process. So something's making that not stick, it should, because earlier on I said, remember, I said that, Header, I said, display flex, and if there's two objects in it, in this case, mob wrapper, where is it? A logo, they should by default sit next to each other, but earlier on when we were messing around trying to do, remember this guy? When we did a slightly different implementation, where we just changed it based on Tablet. 

So in Tablet, we said, here's my Tablet, and I just read through anything that could be messing with it. So in my case anything inside a Header container. So in tablet I'm going, in Header container, or below, so col, nothing to do with it. Hide Desktop only, doesn't seem to have anything in here, with the same name. Header could be, and this is where the problem is. We said earlier on we want it to be Header, everything inside a Header to display Block. That means they stack on top of each other. We could actually get rid of this whole thing. We use that just to build that other style of menu. And that's where the problems come in, it seems weird that I've kind of included in the Class. I guess I know fully well when I'm working on a site, that there's so many things that relate to other things, and you do one thing to fix a problem, and it destroys something else. 

So if I have a Class that always works perfectly, I feel like it's untruthful. So here's our thing, now gets down to this. Turn it off, turn it on. So they're displaying next to each other, which is cool. So this one, it's kind of doing what I want, right? Now what I want to do is, when this clicks it's not kind of leaping out, and we'll do a bit more style, but the basics are there. Who remembers what we did for this? We did it in an earlier menu, our drop-down menu, remember it was kind of like just pushing each other around. So let's first of all stack these buttons, and actually let's not use the My Button. 

Well, because what I want to change the styling of these, and I want to leave them looking like that, on the desktop I don't want to be changing the My Button. So let's call this one Nav Button. 'Command D', 'Ctrl D' on a PC, select them all. Let's have a look at them now. So they're kind of just looking like plain old text. So let's stack them on top of each other, because at the moment they are Inline block. So we need to get them to stack on top of each other. So these guys, on Tablet view, before the ending, closing curly bracket, I'm going to say, Mobile, uh, Nav Button, I would like you to display Block, thank you very much, hopefully. There you go, now they're on top of each other. 

The other weird thing they're doing, is when they are stacking, they're pushing the mobile button, we want to leave that as it was. So what we want to do is we want to make the position Absolute. So this guy here, instead of like being relative to all his friends, so whenever he appears he goes, "Hey guys, we're relatives, I'm relative to you", so I'm going to push you around so I fit. So what we say, over here we say, mob nav, actually, I want to be a positioning, not a relative, Absolute means I ignore everybody else, all my friends all my relatives, and I only acknowledge my parent, which in this case is, who's the parent? Mob wrapper. So it ignores all the rest of the things. In our case there's only one other thing, this image. So it ignores him and just kind of goes back to square one, which is this wrapper. 

All right, let's have a look. Can you see he ignores it, he acknowledges the wrapper, the parent around it, but ignores all of his friends inside. So it's kind of working, we need to push it around and over. One of the other things is that Nav has jammed up on the side there, which is annoying. So let's find that guy, so mob wrapper includes the icon. So we might as well push him all over. So mob wrapper, we'll say, let's have a little bit of Padding. A little bit of Padding on the-- I've typed in path, which is nothing close to it, but got me really close to Padding right. Bit of Padding on the right, I'm going to say 30 pixels. That's good, 30 pixels. Have a look, it's pushed it over enough, let's actually start previewing it. Right click, 'Inspect', let's look at it on, in my case I'm going to iPhone X. 

Remember, if you can't see that, click this little icon down the bottom here, and we're going to use this one. What else we want to do? So it's kind of across, which is cool. Maybe over a bit far, but let's style the buttons, so my Nav Button, let's do a few things to it, let's give it a background color. Background color, will do. Pick a color, I'll pick Coral. Kind of works with what I'm doing. Let's have a look. Let's put some Padding around it, and because this is Mobile, you want to make sure they're really easy to click. So Padding, I'm going to top and bottom. Bit higher than what we did for the rest of them. So 15 pixels top and bottom, and we'll do maybe 30, left and right. When I say maybe, I practiced this. I did this run-through before the class, and I was like, "Yeah, that's big enough," now it's kind of working, but I want to move it across.

So we're editing all our Padding first, because we know how far to move it across. So we'll add some negative margin. So we do margin, left, and we're going to do, margin right doesn't work, just because we've set the position to Absolute. So we're going to use negative left rather than some positive right. In this case, I'm going to say, negative, maybe 60 pixels. Putting it across, kind of close, maybe go a little bit further, 70, looks nice. Toggles nicely, and the text, let's make it center. So text aligned, let's make it center. All right, centered in there. Nice, I want to push it maybe down from this guy a little bit. So the whole wrapper, I might add some Padding to the top. So whole wrapper in my case is called Nav. So mob nav is going to have some Padding. Top. 10 pixels, probably too much. Yeah, looks all right. 

All right, it is working okay. iPad, works. Now iPad's previewing at 50%, because that looks a bit weird, buttons are maybe a bit big on an iPad, and same with this. We can change the size of this obviously down here, to be something smaller, and the buttons maybe don't need as much Padding as I thought they did. One thing that is annoying me is that it's a black stripy line, so you got a couple of options. You can open them up, so we used it earlier on, remember, we had our, Exercise Files, we had Project3, we had this SVG Burger menu. It's a black stripy line, I could just open this in say, Illustrator. Would be the easy one, or XD, and just change it to white, and save it. That's one way, I'll show you a kind of a weird thing. It will be our last thing before in this videos, is SVGs are a weird strange thing. They're not an image file as we know it. The code is actually web enabled, and you can actually see how an SVG is constructed. Let's have a little look, let's go to 'File', and let's go to 'Open'. Let's find, in our Images folder, so Project3, Images folder, I'm in my local folder, not in the Exercise File. Here's the SVG that I'm working with. I right click 'Open', it opens in an actual script, there it is here. 

Let's close down these guys just so you can see, not too confusing. It actually shows you all the kind of styles, just wrapped up in this, like it's, yeah, it's a little bit different from a JPEG. Because you can start to see how it's built, and it's built on top of kind of web syntax, so you can actually understand it. So the one we want, so this is the past. If you are from the Vector path world, these are actually the XY coordinates of everything. It's got some-- this, can you see these? These all come from, where? From these guys here, it's added Classes to it, which is weird, right? Inside of a file, and it is, this is Font Awesome. Remember those classes, FA Banners? What we want is we're looking for the color, can't see it there. Fill with current color, we're going to switch this out to just white. Okay, hit 'Save'. Have a look, oh, yeah, now it's white. You could use regular hashes, so white is FFF FFF, or pick any sort of random color you want, Coral. We'll tie him with the Nav, there you go. Nice. 

So we've got our Mobile Nav working, we'll be turning the desktop off, and then turning the Mobile menu on, and that's the easy part, right? Just turning on and off, and getting the JavaScript to work. Then there's a lot of hassle, we're trying to work out, what styles can stack them, how do we push them across, and that is the real kind of, I don't know, the fiddly parts of setting up a Mobile Nav. That's why testing is really important, because what I'll do is I'll do that right at the beginning, and then, great, go start working with stuff, then start adjusting things like the Head tags, to do different stuff for different reasons, and then later on, like a day later, I'm checking in, like the Mobile Nav's not working, I'm like, "Oh, geez!" You got to go back and figure out what happened, and problem solve that way. If you find yourself in this, and you're like, "Man, I'm a terrible Web Designer.", no, you're just a regular Web Designer. There's a lot of chasing your tail, especially when you're new and you can't kind of predict problems. I find my biggest problem is when I try and reuse stuff, I'm like, "Oh, I can," instead of creating like a separate class or a compound class, I'll just try and layer stuff together to try and be clever, and ruin things. All right, that will be it. I will see you in the next video.
Written Guide

How do you switch a desktop navigation menu to a mobile hamburger menu?

Use a CSS media query to hide the desktop navigation and show a separate mobile menu wrapper at your chosen breakpoint. Keep the mobile links hidden initially, then use jQuery to toggle them when the hamburger icon is clicked. Finally, fix any existing layout rules that interfere with the dropdown.

Switching Desktop to Mobile Menus with CSS and jQuery


Key takeaways

  • Switch between desktop navigation and a hamburger menu at the tablet breakpoint.

  • Group mobile links so one jQuery action controls the whole dropdown.

  • Find old CSS rules that break an otherwise working menu.

  • Style and position the dropdown without moving the header around.

  • Change an SVG icon’s colour and test the result across screen sizes.

A mobile menu can work beautifully on an empty page. Drop it into an existing website, though, and suddenly the logo stacks above the icon, the links push everything around, and some old tablet styling starts causing trouble.

That is the useful bit to learn. Getting the click to work is only part of the job. The rest is making your new navigation get along with the code already there.

We are working with an existing portfolio site that already has desktop navigation buttons and responsive layouts. The goal is to keep those buttons on desktop, then replace them with a hamburger icon and a simple dropdown on both tablet and mobile.

Visual Studio Code split editor displaying HTML header and container markup alongside desktop Flexbox CSS styling rules

The existing desktop navigation stays intact while we build a separate small-screen version.

1. Hide the desktop navigation at the tablet breakpoint

Open index.html and style.css. Having the HTML and CSS side by side makes it easier to check which elements your selectors actually control.

First, decide when the menu should change. In this design, the hamburger menu appears at tablet size, not just on phones. That means we can put the switch in the existing tablet media query and let it continue applying at smaller widths.

Inside that tablet media query, hide the existing desktop navigation:

nav {
display: none;
}

This selector targets the existing desktop nav element. Our mobile links will live in a separate wrapper, so hiding that element will not hide the new menu too.

Resize the browser and check the change before going any further. The desktop buttons should remain visible at large widths and disappear when the tablet rules take effect.

You may already have rules that change the old buttons’ spacing or stack them on smaller screens. Those rules are now potentially redundant. You do not have to untangle everything immediately, but remember they exist. An older rule can still affect a shared parent such as the header, even after the desktop navigation itself is hidden.


2. Create separate wrappers for the icon and links

Underneath the existing desktop navigation, add a new div with the class mob-wrapper. Keep it inside the header, alongside the logo.

This wrapper contains two things:

  • The hamburger SVG image, with the class burgermenu.

  • A second div, with the class mob-nav, containing the mobile navigation links.

The distinction matters. mob-wrapper controls the entire mobile navigation component; mob-nav controls only the links that open and close. If we toggle the outer wrapper, we would hide the hamburger icon along with the links. Not quite what we want.

Reuse the existing hamburger image, including its alternative text and width. Then copy the navigation links into mob-nav.

In VS Code, you can select the links, open the Command Palette with Command+Shift+P on Mac or Control+Shift+P on Windows, and choose Wrap with Abbreviation. Enter .mob-nav, including the full stop, to create the classed wrapper.

Check the closing tags carefully. Both the icon and the links wrapper must sit inside mob-wrapper. If the links appear on desktop even though the outer wrapper is hidden, they may have ended up after its closing div.


Hide the mobile wrapper globally

In the global CSS, before the tablet media query, add:

.mob-wrapper {
display: none;
}

That switches the entire mobile component off on desktop.


Show the wrapper, but not the links, on tablet

Inside the existing tablet media query, add:

.mob-wrapper {
display: block;
}
.mob-nav {
display: none;
}

Now the hamburger icon appears at tablet size, while the dropdown links stay hidden until we ask for them.

Because the tablet media query also covers narrower screens in this stylesheet, the same behaviour carries through to mobile. There is no need to repeat those declarations in the mobile section unless you want to change them.

Keep an eye on the curly braces. Each selector block has its own closing brace, and the media query has another one around all those blocks. Put the new rules before the media query’s final closing brace.


3. Load jQuery and connect the click behaviour

There are two separate pieces to load:

  1. The jQuery library, using the project’s CDN script reference.

  2. Your own JavaScript file containing the menu behaviour.

Place the script references near the bottom of the HTML body, with jQuery first and your custom script afterwards. Create a file named scripts.js and link it from index.html:

<script src="scripts.js"></script>

Inside scripts.js, the behaviour is simple: wait for the document to be ready, listen for a click on the hamburger icon, then toggle the links wrapper.

$(document).ready(function () {
$('.burgermenu').click(function () {
$('.mob-nav').toggle();
});
});

We are using toggle() here for a straightforward show-and-hide action rather than slideToggle(). Method names are case-sensitive: toggle is all lowercase, while slideToggle has a capital T.

The selectors must match your HTML exactly. It is very easy to call the wrapper mob-nav in the HTML and then target mobile-nav in JavaScript. Both sound perfectly sensible, but they are different class names.

Before testing, check:

  • The image has the class burgermenu.

  • The links wrapper has the class mob-nav.

  • The JavaScript uses those same names, with a full stop for each class selector.

  • The jQuery library loads before scripts.js.

If your HTML-checking extension reports errors after adding the script references, inspect them rather than assuming the menu is broken. In this project, the helper extension flagged a valid script reference incorrectly. Extensions are useful, but they can have bugs too.

Now click the icon. If the links appear and disappear, great. The layout might still look dreadful. That is fine for this stage: we have proved the mechanics work, and we can deal with the styling separately.


4. Fix the old header rule that breaks the layout

The header was originally set to display: flex, which lets the logo and navigation sit next to each other. With the desktop navigation hidden, the visible items should be the logo and mob-wrapper.

But an earlier tablet layout introduced a conflicting rule: it changed the header to display: block. That makes its children stack instead.

This is a classic integration problem. The new menu is not necessarily wrong. An older rule is overriding the layout it needs.

Work through the tablet styles and look for selectors affecting the header or its surrounding container. In this case, remove the obsolete tablet header block that was only needed for the previous menu arrangement. That allows the original flex layout to continue working.

The logo and hamburger should now sit alongside one another. We have not added more and more CSS to force them into place; we have removed the rule that was fighting us.

When the result looks unexpected, check the existing rules before adding another override. It is often the quickest route to a cleaner fix.


5. Give the mobile links their own styling

The desktop links already use a button class, but we want the mobile dropdown to look different. Changing that shared class would change the desktop navigation too.

Give the mobile links a separate class, navbutton, instead. In VS Code, Command+D on Mac or Control+D on Windows helps select repeated class names for editing.

Once the old button class is removed, the links may look like plain text. That is expected. We can now style them without disturbing the desktop version.

Inside the tablet media query, make each mobile link a block:

.navbutton {
display: block;
}

This stacks the links vertically, giving each one its own row rather than keeping them side by side.


6. Position the dropdown without moving the hamburger

At this point, opening the links can still push the hamburger icon or stretch the header. The dropdown is taking up space in the normal page flow.

Set position: absolute on mob-nav to take the dropdown out of that flow. The menu can then appear over the page rather than making room for itself by pushing neighbouring content around.

There is an important positioning detail here: an absolutely positioned element uses its nearest positioned ancestor as its containing block, not automatically its immediate parent. If you want the dropdown anchored to mob-wrapper, make that wrapper positioned with position: relative.

With that relationship established, opening the dropdown should leave the logo and icon in place. The remaining work is adjusting the spacing and appearance.

Add space from the right edge

The hamburger is a little too close to the side of the page, so add padding-right: 30px to mob-wrapper within the tablet styles. Because the wrapper contains the whole component, this moves the icon and its associated menu area away from the edge.

Make the links easy to tap

For the mobile links, use a coral background and more generous padding:

.navbutton {
display: block;
background-color: coral;
padding: 15px 30px;
text-align: center;
}

The padding gives each link 15 pixels above and below its text, plus 30 pixels on the left and right. On a small screen, we want a comfortable target, not a tiny word that needs a very precise tap.


Adjust the horizontal and vertical placement

Once the link padding is settled, adjust the dropdown’s horizontal placement. In this layout, a negative left margin pulls the menu back towards the centre of the page. Trying -60px gets it close; -70px gives the preferred alignment.

That is a layout-specific adjustment, not a universal mobile-menu measurement. Set the link dimensions first, then judge how far the dropdown needs to move.

Add padding-top: 10px to mob-nav to create a little breathing room between the icon and the links.

Visual Studio Code split view showing mobile menu markup on the left and responsive CSS overrides

The links now stack in a padded dropdown without pushing the header out of place.

7. Test phone and tablet layouts

Open the browser’s inspection tools and enable the device toolbar. Use a phone preset, such as iPhone X, to check the narrow layout, then switch to an iPad preset.

Check more than whether the menu opens:

  • Does the desktop navigation disappear at the intended breakpoint?

  • Does the hamburger appear on both tablet and mobile?

  • Are the links hidden before the first click?

  • Does opening the dropdown leave the logo and icon stationary?

  • Does the dropdown remain within the available screen width?

  • Do the icon size and link padding feel appropriate on each layout?

Also check the preview zoom. An iPad preview displayed at 50% can make the interface look misleadingly small. Judge the layout with that scaling in mind before changing all the button sizes.

The 15-pixel vertical padding is a useful starting point here, but the tablet buttons may still feel larger than necessary. Refine the spacing after checking both device sizes.


8. Change the hamburger SVG colour

The menu works, but a black hamburger icon is not particularly clear against the dark header. We can change it to white, or use coral to tie it in with the dropdown.

One option is to open the SVG in a design tool such as Illustrator or XD, change its colour, and save it. Another is to edit the SVG directly in VS Code.

Unlike a JPEG, an SVG describes its shapes using text-based markup. Open the actual SVG file from your local project’s images folder and you can inspect its attributes and path data.

The path data describes the vector shape. You do not need to alter that. Look instead for the fill attribute. In this icon, it is set to currentColor.

Replace that value with white and save. You can also use the hexadecimal value #ffffff. To match the dropdown, use coral instead.

Make sure you edit the image used by the local site, rather than another copy in an exercise folder. Otherwise, you can save the change correctly and still see no difference in the browser.


The real lesson: keep testing as the site changes

Showing and hiding two menus is the easy part. The fiddly work is finding the old styles that interfere, keeping the header stable, and making the dropdown sit where you want it.

Test the mobile navigation again after changing shared header styles or reusing classes elsewhere. A menu that works today can break tomorrow because another part of the stylesheet has changed.

I find it particularly easy to cause trouble when trying to be clever with class reuse. Sometimes a separate class or a more specific combined selector is clearer than layering unrelated styles onto an existing one.

If you spend time chasing a CSS conflict, that does not make you a terrible web designer. It makes you a fairly normal one. The useful habit is to separate the problems: confirm the structure, prove the click works, resolve the layout conflicts, then polish the appearance.


Key terms

Breakpoint

A screen-width threshold where responsive styles change. Here, the existing tablet breakpoint switches desktop buttons to the hamburger menu.

Wrapper

An element that groups related content. The outer mobile wrapper contains everything, while the inner links wrapper is the part jQuery toggles.

jQuery toggle()

A jQuery method that switches an element between shown and hidden states. Here, it controls the mobile links when the hamburger is clicked.

Absolute positioning

A CSS positioning mode that removes an element from normal flow. It lets the dropdown appear without pushing the header’s other content around.

SVG fill

The colour used to fill an SVG shape. Editing this attribute changes the hamburger icon’s colour without altering its vector path.


FAQs

Why does my hamburger menu appear on desktop?

Check that mob-wrapper has display: none in the global CSS and is only shown inside the tablet media query. Also check that the icon and mobile links are both inside that wrapper.

Why does clicking the hamburger do nothing?

Check that jQuery loads before your custom script, that scripts.js is linked correctly, and that the JavaScript selectors exactly match the HTML classes. In particular, mob-nav and mobile-nav are not interchangeable.

Why are the logo and hamburger stacked vertically?

An older responsive rule may be overriding the header’s flex layout with display: block. Inspect the tablet styles and remove obsolete rules left over from the previous navigation design.

Why does opening the dropdown move the header?

The links are probably still occupying space in normal flow. Use absolute positioning for the dropdown, and establish the intended positioning reference on its wrapper.

Do I need to repeat the menu rules in the mobile media query?

Not if the tablet media query already applies at mobile widths and no later rule overrides it. Add mobile-specific declarations only when the smaller layout needs a different appearance.

Daniel Walter Scott

Written by Daniel Walter Scott — Founder of Bring Your Own Laptop & Chief Instructor

  • Powered by Marvin
  • Terms of use
  • Privacy policy
  • Cookie policy
  • © Bring your Own Laptop Ltd 2026

Say hello to our brand-new Photoshop Essentials course! 🎉

Join Bret and start building your Adobe Photoshop skills from the ground up. Designed for beginners, this course will help you get comfortable with the essentials and gain confidence as you bring your ideas to life.

Whether you’re opening Photoshop for the first time or returning for a refresher, there’s plenty to discover. Grab your laptop, settle in, and let’s get creative!