Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Whats wrong with this?

Hi,

I want to make my header and nav bar to extend 100% with their background but to set them in the centre to the web page.

While I'm doing it here , it somehow works on 50% . Could you guys help me solve this please?

2 Answers

Ok gotcha.

Set the background color on the outside div and make the inner div 50% wide. Then you can center the whole inner div (and everything inside it) using margins.

You can see how I did it on this Plnk

Hi, thanks!

At the moment im in college and coding is a pain and workshops hardly works and at the moment , with the mess I got , the header look fine!

What im more worried is about the nav but ill check It when I get at home.

But that's nice!

Thank you! :smiley:

Actualy xd I think I use what you are using since it works perfectly fine at college xd

So you want to have them span 100% the width of the browser, but to be aligned to the center?

If so, try to use the text-align property in the elements you would like to align to the center.

Hi, no i don't want actually the items aligned to the centre.

I want the content to be aligned to the centre so this means that the 1200px box, is aligned on the centre but the background go across 100% of header and nav colour.

basically like this http://www.gateway.ac.uk