Skip to main content

How to switch a menu nav from desktop to mobile phone

Lesson 96 from: Build a Responsive Website Using HTML5 & CSS3

Daniel Walter Scott

How to switch a menu nav from desktop to mobile phone

Lesson 96 from: Build a Responsive Website Using HTML5 & CSS3

Daniel Walter Scott

buy this class

$00

$00
Sale Ends Soon!

starting under

$13/month*

Unlock this classplus 2000+ more >

Lesson Info

96. How to switch a menu nav from desktop to mobile phone

Lessons

Class Trailer

Getting Started

1

How This Class is Structured

01:41
2

What to Download

02:57

Introduction to HTML & CSS

3

Creating Our First Webpage

05:55
4

What is HTML5 & CSS3

08:24
5

Head vs. Body vs. Html Tag

09:01
6

Title & Description

05:54
7

What Code Editor Should I Use

02:42
8

Using Diy Tags

06:26
9

What is a CSS Class

09:05
10

How to Create Nested Divs

05:03
11

Class Project

05:24
12

External CSS

09:07
13

Creating Our Index Style Pages

12:16

Project 1: Restaurant Website

14

Testing Your Website

08:47
15

Check Your Code For Errors

11:01
16

What are HTML5 Structure Tags

05:47
17

Add HTML5 structure elements

16:02
18

How to Set the Color of the Background

05:10
19

Adding Images to a Website

04:38
20

How to Center an Image

01:14
21

Change the Font Size & Color

14:11
22

Make a Clickable Link

08:45
23

Stretching Background Image

05:38
24

Making a Div Tag Transparent

02:36
25

Simple Website Text Navigation

06:43
26

CSS Compound Classes

07:02
27

Class Project 02

02:05
28

Class Project 02 - COMPLETE

04:48
29

Add an Email Button to a Website

03:49
30

Add Google Maps to Your Website

11:25
31

Making a Website Live

16:50
32

Uploading via SFTP

11:50
33

Setting Up Our New Project

03:46

Project 2: Bike Repair Website

34

CSS Reset

15:22
35

Min-height vs. Height

07:01
36

Div Tags Onto One Line

05:23
37

Getting div tags onto one line using Flexbox in HTML & CSS

05:23
38

Evenly Spaced Div Tags

04:42
39

Two Div Tags of Different Sizes

07:13
40

Vertically Center Content

07:20
41

Class Project 3

02:51
42

Class Project 3 - COMPLETE

05:39
43

Change Default Fonts

04:19
44

Installing Google Fonts

12:44
45

What are PX & EM & REM

14:56
46

Change Line Height

04:33
47

SVG vs. JPG vs. PNG

07:04
48

How to Create a SVG, JPG, or PNG

11:00
49

Block Images vs. Background Images

08:32
50

Finishing Up Our Cards

09:10
51

Icons via Font Awesome

16:31
52

Making a Div Container Clickable

09:55
53

Box-sizing & Border-box

06:19
54

How to Make A Colored Button

07:46
55

Why Can't I Add Margin or Paddding

11:08
56

Rounded Corners

04:17
57

Drop Shadows

06:24
58

Backup Your Website

05:00
59

Reusing a Button Class

03:10
60

Class Project 04

02:58
61

Class Project 04 -COMPLETE

05:45
62

Adding a Horizontal Rule

03:51
63

Make Divs Wrap Onto Separate Lines

12:14
64

Hover Color & Animating a Button

03:33
65

Pseudo Classes

09:31
66

Simple Dropdown Navigation

20:04
67

Adding Our Dropdown to the Website

14:50
68

Useful Shortcuts and Tips in VS Code

13:28
69

Large Background Image

09:24
70

How to Connect 2 Pages

10:42
71

Simple PHP Form Work

17:49
72

Placeholder Form Text

05:46
73

Multi Line Form Text Box

02:18
74

Form Check Marks

03:04
75

Form Radio Button

06:07
76

Form Drop Down Menu

05:48
77

How to Style Your Form

12:55

Project 3: Responsive Portfolio Website

78

What does responsive website design mean

04:17
79

How to change a website layout size color when at different sizes using media queries

11:28
80

How to test your website on a tablet or mobile phone from Visual Studio Code

06:00
81

How to change the layout of a responsive website for mobile vs desktop

16:02
82

How to turn things on and off for mobile tablet & desktop responsive websites

06:03
83

What is pixel density responsive images pixel ratio dp px in webdesign

14:47
84

How to export responsive images for website from XD Photoshop Illustrator

05:11
85

How to add responsive images to website using 100% width in HTML & CSS

06:08
86

How to use srcset to change images in HTML for responsive website

10:15
87

How to add a css style to the first line of a p tag on a website (

11:18
88

How to make the header footer full width but the inside centered

05:36
89

Class Project 05 – Header design

03:12
90

Class Project 05 – Header design COMPLETE

06:25
91

How to use a span tag or span class in HTML to change text

10:32
92

How to pin the navigation to the top of a website fixed nav

03:17
93

How to make a simple responsive mobile menu using CSS only

08:21
94

What is Javascript vs Jquery in website web design

06:35
95

How to make a burger menu 3 line mobile navigation for a website

15:11
96

How to switch a menu nav from desktop to mobile phone

21:45

Project 4: Bootstrap Yogurt Website

97

Overview of what Bootstrap 4 is in website design

07:57
98

How to install Bootstrap 4 on a website using Visual Studio Code

06:27
99

Quick overview of how the Bootstrap Grid Layout works in VS Code

10:49
100

Quick overview of how Bootstrap Components works in VS Code

09:23
101

Quick overview of how Bootstrap CSS Styles works in VS Code

08:20
102

How to customize the default Bootstrap 4 css styles

13:51
103

How to use Bootstrap Layout Grid Experiment 1

10:20
104

How to make 100% header & uneven widths in Bootstrap 4

07:16
105

How to create uneven col widths in Bootstrap 4

07:27
106

How to add padding & margins using Bootstrap 4 in VS Code

12:03
107

How to change layout of Bootstrap depending on mobile or desktop

15:46
108

How to turn things on & off on your website using Bootstrap 4

05:30
109

Google Chrome Inspect

12:40
110

Add Shadows to Text & Boxes

07:06
111

Change the Default Buttons

06:16
112

Responsive Images in Bootstrap 4

09:34
113

How to Center Text & Div Tags

04:16
114

Customize the Bootstrap Navbar

07:29
115

Add Your Own Logo

03:58
116

Change the Default Nav Styles

12:12
117

Fix the Navigation to the Top

04:41
118

Col Images & Col Background

07:56
119

Bootstrap Border & Rounded Corners

04:20
120

Bootstrap 4 Carousels

05:13
121

Card Groups

03:29
122

Drop Shadows On Bootstrap Cards

02:25
123

Clickable Boxes in Bootstrap 4

04:02

Final Quiz

124

Final Quiz

Lesson Info

How to switch a menu nav from desktop to mobile phone

Hi there, this video, we are going to implement our really simple mobile nav that we built in the last video into our full site. Okay. Where it goes from this to desktop to mobile with a sweet little dropdown now we kept this one separate so that we could really kind of focus on implementing j query but now we're going to fold it into our largest site and like this side 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 that simple where you've just got this clean clear, you've got to do battle with existing bits of code like our case. We've got this weird little dropdown thing here, we're gonna 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. Alright, so we're going to open up our existing site, I'm gonna open up index dot html. Double clicking it. Open up style dot CSS drag style over here and let's get started. So the first thing I want to do is we're going to turn let's turn knob off when it gets to the tablet screen. Okay. My mock up decided to go to this mobile menu even at tablet. Okay, so um it's gonna be on for both of these so let's go and turn what we currently have off. Okay and actually this is preview it what we got always a person the wrong page and so it gets down to here and it switches out. That's what we did previously. Right that it is definitely an easy way to do it. Okay, we're going to do it without javascript now so what I want to do is instead of flicking around I want to just turn all those buttons off and we're gonna turn our mobile version on so in bs code we are going to find our nav. Okay, so this knob here is going to turn off when it gets to tablet so I'm gonna go tablet view. I'm gonna double check, I don't have anything else trying to control knob this here. Okay, nope. So I'm just going to say just above here, I'm going to say never. And you get to tablet mode display None. Cool. Now you were 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 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 oh this bit controls it all this bit's messing with it so this one's gonna be a little bit messy but for good reason so we can learn how to fix it. All right, so we're gonna ignore all that. Let's just make sure it actually turns off for ready. There you go. So when it gets down to tablet mode and down to mobile it turns off cool. So what we want to do now is have something else turn on our little stripy line so let's go back to the s code underneath Nav. What we'll do is we'll create another div tag and we'll call this one dot and let's call this one mob hyphen rapper, we're gonna put everything inside of this. Okay so inside my mob rapper we're going to add our icon of those little three stripey lines for our mobile Nav plus another set of these. Cool so let's grab let's cheat, let's grab our image. Okay, so open up the bakery nav and this is the chunk we want. Okay that's the icon that we brought in the image and svg we had a small text, we added a width and we gave it a class of burger menu so we're just gonna cheat because we're like already done that. Alright so we've got them in, he just happens to be that wrong. Here we go, let's just check, he actually appears clean it all up. All right there he is. Okay 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, okay 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 them on fire we'll turn them on a 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 I always have to at the end if you don't things will go wrong. Alright so we're going to say who we want. Dot mob rapper I would like you my friend and everything inside of you to turn actually we don't want to do anything for him yet. Okay I want to cut him out and I want him in desktop view to turn off Okay so just before the closing or opening of the tablet I'm gonna say mob rapper you are a display of none please. So he's off on desktop which is perfect but he never turns back on. Okay so now we need to say so he's off on desktop and then as it goes through it's gonna say alright on tablet though I'd like to turn him on down the bottom here before our curly brace, we're going to say display block and he's back on. Alright, so off on this top 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. All right, next thing is I want all the bits off the side that we're gonna turn off, remember all the buttons that are going to drop off okay that we want activated by this little click. So what we need is we could just go and steal all of this. Okay, so all these buttons here actually we'll grab, you know, grab these buttons. Okay. And so there's my image underneath my image before our wrapper closes. Okay, so there's my rapper ends there just after the image I'm going to put in. These guys these guys need to be in their own a div tag. Why? Because they're kind of just floating around a bit at the moment. They've got no kind of no grouping. Okay, this guy's by himself. These guys, these three, these guys need to be tied together so command shift p. Control shift P. Okay, start typing wrap and we're gonna use wrap with abbreviation and I'm going to wrap them up in something called something I'm going to make up right now called mob nav. Never come on dan, you can see the geese. Alright. Maznov and it has to have a period in front of it. Okay, so wrap with abbreviation dot mob nav. Alright, 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 rapper that were turning on and off. If you still see them, it means you've probably got these guys after this closing div Okay. It needs to be inside Nice. So often desktop 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. Okay, so let's turn it off by default. This little mob nav. Okay, that's why it's good in a wrapper. Okay, because we can all off and one that will go so I'm gonna say on tablet view, mob nav mm dot mob NEv I would like you two just be off display display. None Alright, can't see them. I'd like to turn them on with javascript when this thing is clicked. Alright, so to implement our javascript and j query in this case we need to do two things. Remember we need to load the library Okay, which is the kind of all the rules around javascript Okay, or J query and then we need to actually put it around custom coding so just like we did before we're going to go to our exercise files. Your exercise files there is project three there's one in here called J query mobile neV Okay. Open that up and that's the Cdn. Okay. 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. Okay. But it's more common to put it down here in the body. We talked about the reasons why before and 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 up here 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. But so we're just going to have to ignore that. So the extensions are great. Built by other people. It's a bug in this particular one. Will this person who runs this um extension go and fix it mike. I'm not sure. Maybe it's something that can't be fixed. Okay because of he just needs to check for these different things. So I guess it'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. Okay. And in our case, in my case this is working just fine. So we've 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 gonna save it And I call this one scripts scripts dot Js Okay. And I'm going to paste in my text. Okay. 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 of is I don't like the slight toggle to toggle. You'll notice that the toggle by itself is not uppercase. Okay. 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. Okay. 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 stripey 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 dot html we're going to load our script so we're gonna go to script source. Okay. You're gonna get a bunch more errors and we're going to say it is sitting in, it's just called scripts, scripts dot 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 okay burger menu matches up okay with the rapper that I've got. So I mean the class that I've got applied to my icon is my icon and I applied that class called burger menu. Perfect. So that matches that next one is called mobile Nav. Okay. So I want to turn this on and off. I haven't called it mob Nav. Okay, I've called it mobile Nav. So I've mixed up the names so just got to make sure that mob Nav is in here. It's just 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 he Okay. So it turns it on and off the layers all broken. But it's okay. The mechanics work. And that's what's I guess their most important for now. Now the reason this is happening and if you're following along with me exactly in this course, you probably have the same problem. You might not. Okay. You might because like I want this guy up next to it and 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 it 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 flicks. Okay. And if there's two objects in it and in this case mob mob rapper. And 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 the tablet. So in tablet we said here's my tablet and I just read through anything that could, that could be missing with it. Okay. So in my case anything inside ahead of container. So in tablet I'm going okay and hit a container or below. So cold. Nothing to do with it. Hi desktop only doesn't seem to have anything in here with the same name. Hit it could be okay. And this is where the problem is we said earlier on, we want the header, everything inside a header to display block. And that means they stack on top of each other. Let's we can 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 like it seems weird that I've kind of included in the class. I guess I know full 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 the problem and it destroys something else. Okay, so if I have a class it always works perfectly. I feel like it untruthful. Okay, so here's our thing. Okay, 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 that's kind of doing what I want right now I want to do is win 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 dropdown menu, remember it was kind of like just pushing each other around. So let's let's first of all stack these buttons and actually let's not use them my button. Well, because 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. Never been. Okay. Command D Control d on the pc. Stick them all. Let's have a look at them now. Okay, so they kind of just looking like plain old text. So let's stack them on top of each other because at the moment they are in line block. Okay, 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 never 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 is they're doing is they're 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 when when did he appears he goes, hey guys we're relatives, I'm relative to you so I'm gonna push you around so I fit. So what we say over here is you say mob never actually I want to be a positioning not a relative. Okay, absolute means I ignore everybody else. Okay all my friends, all my relatives and I only acknowledge my parent which in this case is who's the parent mob wrapper. Okay so it ignores all the rest of the things in our case is 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 so look you see he ignores it but he acknowledges the rapper the parent around it but ignores all of his friends inside. Cool. So it's kind of working we need to push it around and over. Okay 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 them all over. So mob rapper will say let's have a little bit of padding, A little bit of padding on the I've typed in Pa which is nothing close to it, but it got me really close to a petting right? It's a bit of padding on the right. I'm going to say pixels. Have a look. Let's push it over enough. Let's actually start previewing it. Right click inspect and let's look at it on. In my case I'm going to I a phone X. Remember if you can't see that. Click this little icon down the bottom here. Okay. And we're going to use this one. All right. What else do you want to do? So it's kind of a cross which is cool. Um maybe over a bit far. But let's let's start the buttons. So my next button. Let's do a few things to it. Let's give it a background color background color will do pick a color 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. Ok so padding I'm going to top and bottom bit higher than what we did for the rest of them. Okay, 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 glass and I was like yeah that's big enough now it's kind of working okay but I want to move it across so we're editing all our padding first. We know how far to move it across. So we'll add some negative margin so you can imagine left And we're gonna do margin right. Doeses't work just because we've set the set position to absolute we're gonna use negative left rather than some positive right? In this case I'm going to say no I'm negative maybe 60 pixels putting it across. It's kind of close, maybe go a little bit further this evening. It looks nice toggles nicely. And the text let's make it center. So text align. Let's make it center. Oh, alright send it in there. Nice. I want to push it maybe down from the sky a little bit so the whole rapper, I might add some padding to the top. So the whole wrapper in my case is called nev so mob never is going to have some padding top of 10 pixels. Probably too much. No, that looks all right. All right, it is working Okay. I paired works Now. Ipads previewing at 50% because that looks a bit weird buttons are maybe a bit big. Okay on ipad and same with this we can change the size of this obviously down here. Okay. To be something smaller and the buttons maybe don't need as much padding as I thought they did. Um one thing that is annoying me is that it's a black stripe the line. So you've got a couple of options, you can open them up and so we used it earlier on. Remember we had our exercise files, we had project three, we had this SVG burger menu. Okay. And it's a black stripe in line. I could just open this in say, illustrator would be the easy one or XD. Okay. And just change it to white and save it. That's one way I'll show you a kind of a weird thing would be our last thing before in this video is SVG Zara. Weird. Strange thing. They're not an image file as we know it. Okay. The code is actually web enabled and you can actually see how an SVG is constructed. Let's have a little look. It's got a file and let's go to open. Okay, And let's find in our images folder. Project three images folder. I'm in my local folder. Not in the exercise file. Okay. Here's the SVG that I'm working with. I like, like open. It opens and it's an actual script. Okay. There it is here. Let's close down these guys just so you can see they're knocking 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 what, how it's built and it's built on top of kind of web syntax so you can actually understand it. Okay, so the one we want. So this is the path. Okay, if you are from the victor path world, these are actually the X Y coordinates of everything. Okay. It's got some this you can see these these are 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 um font awesome. Remember those classes. Okay, font FAA bars. All right. And what we want is we're looking for the color. I can't see it there filled with current color. We're going to switch this out to just wait. Okay, hit save, have a look. Yeah, now it's white. You could use regular hashes. Okay, so what is F. F. F. F. F F. Okay. Or pick any sort of random color you want? Coral. Maybe it's time with the Nav. Here you go. Nice. Alright, 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 with 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 and 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 and then start adjusting things like the head tags to do different stuff for different reasons and then later on like, you know, a day later I'm checking and I'm like the mobile nerves not working, you're like underneath, you gotta go back and figure out what happened and problem solved that way. If you find yourself in this and you're like man, I'm a terrible web designer, nope, you're just a regular web designer. There's a lot of chasing your tail, especially when you're new and you can 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 trying to lay your stuff together to try and be clever and ruin things. All right, That'll be it. I will see it in the next video

Class Materials

Bonus Materials with Purchase

Exercise Files
Completed Files

Ratings and Reviews

Viwosoft Technologies
 

Great tutorial - your clear instructions and concise explanations make learning HTML5 & CSS3 a breeze!

Student Work

RELATED ARTICLES

RELATED ARTICLES