How to turn things on and off for mobile tablet & desktop responsive websites
Hi there. I can tell from your face that you wish this was a video about turning things on and off depending on if it was mobile or tablet you're in luck my friend on tablet view, we've got box 12 all the way through to 10 all of them. But on desktop. Okay. Because we've got three columns across, only want nine. I want to turn 10 off and it's gone. Look then on mobile we wanted to box 123, four and then I turned a chunk of them off and just turned 10 back on just for kicks. So this video is going to show you how to turn things on and off using CSS and media queries depending if you're on mobile or tablet. The short version is okay, basically just apply a special class with display. None apply it to the things you want to turn off and it'll turn off but for the long version and all the good stuff. Hang about, let's jump in and work out how to do it. Alright to add it, we need to create a class in our CSS. That turns it off. Okay? And then apply that class to the thing you want to turn o...
ff. So the style in our case is remember on desktop view. Okay let's swim out is I want nine of them showing. So it's nice and even Okay I don't want that extra one hanging out which it currently does. There's this guy, I don't want you there. Okay these and then so when we get to this view We can turn out 10 back on even though I've only got eight here. 10 will fill it up still nicely. But in our mobile I want to turn them all back on because it doesn't really matter how many I have. So let's have a look at doing that. So we're going to create a class. Okay. We're going to call this one hide desktop only. It's a bit long. Um I wouldn't call it this. I'd probably call it H or high D Okay. Just to make it smaller but we'll try and make it really explicit so it's really easy to work out in this class. Okay. And all we're going to do is say display. We've done block we've done in line block. We've done flex, we're gonna do none. Okay. Goodbye. Okay. So it's in my kind of global stuff which means I'm targeting desktop. Okay. If you want to turn it off for tablet you probably change the name of it and have it in here. Actually. We might do that in this video just to really kind of explain what we're doing. So now I need to because it's really long I'm just going to copy it, apply it to something. So box 10 here we want to add two classes so make sure there's a space between the two separate classes. Make sure it's inside your quotation marks. And hopefully now on this view here it's going to turn off. Okay. It's gone the rest of you but it's going on this view as well. Okay, tablet and mobile it's because of that kind of flow. Okay. It flows through here and there's nothing else telling it to come back on. So we have to do is grab all of this including the curly brace. Make sure when you are pasting this, believe that guy there, he needs to be there the kind of closing of this media query. I'm gonna paste this in. Okay. And I want to turn it display to block Okay, just show it up again and I don't need to tell it for this because it will flow through onto mobile hopefully. Okay, so on just stop, I'll get nine and I can't scroll down any further on tablet though. Here we go. Box 10 appeared and then on mobile it should be there as well. Okay, let's just say on mobile. Okay. We need to turn a bunch of them off because it's just maybe it's scrolling really long. Maybe you've got like 50 and on tablet you've got, you know, 40 but on mobile you just want 10. Okay, let's just pretend that that's what we want to do. So India's code we need to create another class and I only want to activate it at mobile. Okay, so before the last curly brace there I'm going to say I want one called hide mobile only. I'm not sure why the mobile only just call, just call it that seems simpler. Okay. And same thing display none. And because it's linked into this CSS it's only to what you applied to but it's going to take effect kind of makes sense. So what am I going to do? I'm going to do some multiple curses which is command option on my Mac or control option on a pc. You're sick of me telling shortcuts, aren't you? Space and I'm going to call this. Well, I'm not going to call it. I'm going to grab hide mobile. Hopefully all of these are going to turn off 10 is not, it's going to be there because I left it off this little group. Let's have a look. So this of you. Okay. I've got nine tape of you. I've got all 10 and then a mobile I've got we've got 1234 and 10. Alright. We're making responsive stuff. It's not very pretty, but we know how to add text and images. We're going to do it for this site because responsive images are quite important. We'll get onto that next. But I hope you're getting used to the using media queries both to do text changes but also to do things like structural changes and turn things on and off. Now. We've just done simple things like turning boxes on and off. You could completely change your website for mobile. Okay. It might be important that when people are searching for your site, like I do it for my new Zealand business, it's more of a like a sit down classroom business. Right? So people come do adobe courses or web design courses. But actually physically turn up to what we do is women are viewing it on desktop. We show them information because we know that likelihood is there and they're looking to buy a course. We give them information about that. But when they're on the mobile, we changed the homepage to be very clear our address and phone number. Okay. Because that's more useful for somebody on their mobile when they're normally rushing to try and they're late for the class or they can't find the building. So you can turn on a huge you could turn dibs completely on and off. Okay. They have a nice cool map in it. Okay. Or directions or make the phone number really clear on the home page. It's not really useful on the desktop view but be really cool to have on mobile. All right. You get the idea we're turning things on and off using display. None that one. All right. I'll see you in the next video