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

General Discussion

Changing CSS background-color causes nav to change size :S

This is the code I am using:

<div class="navbar-container">
        <div class="container">
            <ul id="navb">
                <li class="navli"><a href="#">About Us</a></li>
                <li class="navli"><a href="#">Our Products</a></li>
                <li class="navli"><a href="#">FAQs</a></li>
                <li class="navli"><a href="#">Contact</a></li>
                <li class="navli"><a href="#">Login</a></li>
            </ul>
        </div>
    </div>

and this is the CSS I am using:

.navbar-container {
    width: 100%;
    height: 2.7em;
    background: -webkit-linear-gradient(#15377e, #102B63); /* For Safari 5.1 to 6.0 */
    background: -o-linear-gradient(#15377e, #102B63); /* For Opera 11.1 to 12.0 */
    background: -moz-linear-gradient(#15377e, #102B63); /* For Firefox 3.6 to 15 */
    background: linear-gradient(#15377e, #102B63); /* Standard syntax */

}

    #navb {
      width: 100%;
      float: left;
      margin: 0 0 3em 0;
      padding: 0;
      list-style: none;
      background: #f2f2f2;
      border-bottom: 1px solid #ccc; 
      border-top: 1px solid #ccc; }

    #navb .navli {
      float: left; 
    }

    #navb .navli a {
      display: block;
      padding: 8px 15px;
      text-decoration: none;
      font-weight: bold;
      color: #069;
      border-right: 1px solid #ccc; }
    #navb .navli a:hover {
      color: #c00;
      background-color: #fff; }

Now the issue I am having is that whenever I change the background of #navb it suddenly changes in size which has confused me a lot.

Here is an example:

http://screencast.com/t/PwsInXPw

As you can see when I change the background colour it changes, or the border disappears I haven't had that much of a good look at it.

I am using Bootstrap so I wonder if it is Bootstrap related?

Any help would be great :)

1 Answer

Hi Nicholas,

It seems what you're trying to show in the video is that after changing the background to blue, the links appear to grow 1px in height when you hover over them.

Is that what you mean by the size change?

If so, I think this is just an illusion you're seeing based on the color choices. There isn't enough contrast between the blue background and the gray top and bottom border. You don't really see the border. Then when you hover over the link and the background changes to white there is enough contrast that the border "pops out" at you and it seems to be taller than the rest of the links.

Let us know if you were talking about something else. That's all I can figure right now based on what the screencast shows.