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

Matt Jones
Matt Jones
1,950 Points

CSS Portfolio styling, need help!

I've been following the tutorial on how to create and deploy a website and I'm having some trouble with the NAV. Instead of the NAV being in a border that stretches across the entire screen, it's contained within three separate boxes.

Not sure what the specific CSS would be to change this, I'm a green horn to coding and could do with a nudge in the right direction.

8 Answers

Bryce Santos
Bryce Santos
11,157 Points

Post your code. Click on the cheatsheet below the reply box so you can post the code easily.

Bryce Santos
Bryce Santos
11,157 Points

Both HTML and CSS, as well :)

Matt Jones
Matt Jones
1,950 Points
nav {
text-align: center;
  padding: 10px 0;
  margin: 20px 0 0;
}


nav ul {

  margin: 0px 10px;
  padding: 0;

  }

nav li {
display: inline-block;
}

nav a {
  font-weight: 800;
  padding: 15px 10px
}
Matt Jones
Matt Jones
1,950 Points
    <nav>
      <ul>
         <li><a href="index.html" class="selected">Portfolio</a></li>
         <li><a href="about.html">About<a/></a></li>
         <li><a href="contact.html">Contact</a></li>
      </ul>
    </nav>
Bryce Santos
Bryce Santos
11,157 Points

The nav borders the li elements like it's supposed to. The li elements are the items that are sectioned off in 3.

Matt Jones
Matt Jones
1,950 Points

I've downloaded the CSS file and renamed it so I can compare the two and the code is the same, I'm not sure if there's an issue somewhere else further down.

Bryce Santos
Bryce Santos
11,157 Points

So imagine this: The nav is a box that's spanning the screen from left to right and containing 3 separate boxes, the 3 li's. Are you trying to make sure those 3 li's span the screen from left to right within the nav box?

Matt Jones
Matt Jones
1,950 Points

alt text

https://ibb.co/b7DFyF

The top bar is what the NAV looks like with my code. The second bar in the image is how it should look.

Bryce Santos
Bryce Santos
11,157 Points

One of the problems is your HTML. You have an extra </a> after About.

Bryce Santos
Bryce Santos
11,157 Points

Don't forget to close out your nav a padding style. You forgot a semi-colon there.