This lesson is exclusive to members

Responsive Web Design Essentials - HTML5 CSS3 Bootstrap

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

Daniel Walter Scott

Download Exercise Files Download Completed Files

Contents

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.

Introduction

I recommend hosting your new website with Bluehost, you can get a big discount by signing up with this link: https://www.bluehost.com/track/byol/byol_webess_89

You need to be a member to view comments.

Join today. Cancel any time.

Sign Up
Hi there, this video we're going to make a navigation along the top here that, part of it stretches all the way to the outside, but part of it is lined up, the logo in the navigation here line up with the structure of the rest of this website. The coding is not particularly hard, we've just got a wrapper container that goes 100%, inside of it, nested inside is its child, and it's just a fixed width box. Seems simple, but when I first kind of tried to do it, it's a weird old inception type thing, where, "Who goes where?" "Where's what?" "Inside of what?" All that craziness is explained in this simple video, I'll see you in a sec. 

So you can see my dilemma, I have two things, I want this to go all the way to the edges, but the inside part is to stay here, so basically it's just two nested Divs. Nothing to do with this guy down here, this guy could not exist and it would still work. So we're going to forget about the container, we're going to move him down, and we're going to grab it all and make it look pretty, just because. Format Selection, there we go, so it's now indented nicely.

So that's the beginning of the page. I'm going to add another container called Header container. And that guy's going to, all he's going to do is stretch 100% width, which is exactly what he does anyway. I'm just going to put it about there, the beginning. So this guy is, what is it called? Header Container. I consistently spell that one wrong. We don't have to do width, right?, because by default it should reach left and right. So let's put a background color, Background color, I was going to pick gray. Click black, I'm going to drag this around. Yeah, that will do. 

So got a gray in there, and we need a little bit of a height, so we'll just put in a min height for the moment, just so we can see it. Put it in 100 pixels. Let's have a look in the browser, there we go. By default it will stretch all the way along, it's a Block level element, because it's a Div, so it pushes it down, and it's got a background color. Let's put a little bit of margin on it while we're here. So we'll go Margin, 'Margin bottom'. I'm going to put in, not even sure, 40 pixels, let's have a look. Get over to the wrong one, yeah, 40 pixels is fine. Now we need to put this internal container. 

So we just need, inside of our container we're going to put another Div called-- actually not, I'm going to use the Header, so we can use the pre-made tag. He can go in here and we'll style him. So what do we need to do for this fella? Let's just get a background color for him first. Header. Doesn't need the full stop, remember, because it's a regular old html5 tag, and I am going to do two things. I'm going to give it a width. So we're going to match whatever we've got our container for. So let's just steal that. So I've got max-width, let's give it a background color not for any good reason, just because I want to show you where it kind of finishes. We'll use blue violet, it's going to be exciting. Let's have a little look. Not sure even, it won't, so it needs a minimum height. 

I'm going to get rid of these minimum heights, both of them in a second, because I don't need them, and it's almost there. So it's the right width, it's inside this but it needs to be centered. Remember how to do that? So this Header needs to be margin, the left needs to be Auto, and the right needs to be Auto, but the top and the bottom have to be 0. So '0', 'Auto', should do it. Here we go, now we put stuff in here and it would be in the center, but if we get rid of the background color it's not going to be visually see-able. It's not a word, I know but--

So what we're going to do now for the rest of the video, is you do the same for the Footer, just needs to be outside of the container. Don't want it inside of there because that container is forcing it to be a width. So just make sure it's outside this guy, and put in a Footer instead of Header, and do the exact same thing, where you need a Footer container, and then your Footer inside of it. What I want to do now though is edit some basic elements, so that I can set some tasks for you to do on your own in the next video. 

So let's put in some core parts. So at the moment we have a Header with a big purple background, which we don't need anymore; goodbye. Actually I'll leave that in there and comment it out, so that in case yours isn't working you can check mine. And inside the Header I want two tags. Remember, there's no such thing as a logo, like predefined one like Header. So we have to add our own Class, and inside of this is going to be some text. It's just my name, I paste it in there. And also in there, just afterwards is going to be another Div tag called Nav button, remember there is a specific name for that called Nav. 

What if you did dot nav, '.nav', it wouldn't matter. It would work just as good, but we should try and use the correct semantic markup, and there is some text about Pricing, Contact, you just type those in. What does it look like now? Not very good, but it's enough to get us going for our next project. Get ready, homework time in the next video, I'll see you in a sec.