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

Space below main-nav

There is a space below main-nav in larger screens that I can not get rid of. My .main-nav sits higher than .name in the header. Any suggestions?

/* ================================= 
  Base Element Styles
==================================== */

* {
    box-sizing: border-box;
  border:1px red solid;
}

body {
    font-family: 'Varela Round', sans-serif;
    line-height: 1.6;
    color: #3a3a3a;
}

p {
    font-size: .95em;
    margin-bottom: 1.8em;
}

h2,
h3,
a {
    color: #093a58;
}

h2,
h3 {
    margin-top: 0;
}

a {
    text-decoration: none;
}

img {
    max-width: 100%;
}

/* ================================= 
  Base Layout Styles
==================================== */

/* ---- Navigation ---- */

.name {
    font-size: 1.25em;
  margin:0;
}



.name,
.main-nav{
  text-align:center;
}


.name a,
.main-nav a {
    text-align: center;
  display:block;
  padding-top:15px;
  padding-bottom:15px;
}

.main-nav a {
    font-size: .95em;
    color: #3acec2;
    text-transform: uppercase;
}

.main-nav a:hover {
    color: #093a58;
}

/* ---- Layout Containers ---- */
.container{
  width:95%;
  margin:0 auto;
  padding-top:1em;
}
  .main-header{
    width:100%;

  }

.banner {
    color: #fff;
    background: #3acec2;
  width:100%;
}

.main-footer {
    background: #d9e4ea;
    padding: 2em 0;
    margin-top: 30px;
  width:100%;
}

.banner,
.main-footer{
  text-align:center;
}

/* ---- Page Elements ---- */

.logo {
    width: 190px;
  display:block;
  margin:0 auto;
  padding-top:3em;

}

.headline{
  text-align:center;
}

.tagline{
  display:block;
  text-align:center;
  padding-bottom:3em;
}

/* ================================= 
  Media Queries
==================================== */

@media (min-width: 769px) {

  .header-container{
    width:80%;
    margin:0 auto;

  }

  .name{
float:left
}

.name{
  float:left;
}

  .main-nav{
    float:right;


}


.main-nav li{
    display:inline-block;
    float:left;
    padding-left:20px;
    padding-right:20px;

  }

.container{
  width:80%;
}

  .primary,
  .secondary{
    float:left;
    width:50%;
    padding-left:1em;
    padding-right:1em;
  }

.main-footer{
  text-align:center;
}


    /* ---- Float clearfix ---- */

    .clearfix::after {
        content: " ";
        display: table;
        clear: both;
    }

}

@media (min-width: 1200px) {
.container{
  width:90%;
}  

.secondary, .tertiary{
    width:25%;
}
.primary{
  width:50%;
  }

.col{
  float:left;
  padding-left:1em;
  padding-right:1em;
}
}

2 Answers

Hi,

are you working on the code in workspaces currently?

if so can you post the link, or post a snapshot of the code using the camera icon in the top right :)

Craig

Hi,

I have taken a look through it and I can not spot any errors.

The way I can get rid of the gap is simply by adding 3px padding to the top and bottom.

The reason this is mostly likely happening is the float property and it is not an error as such.

I have also ran the code through HTML Validator and CSS Validator and there are no errors or warnings so all is good!

Hope this helps

Craig

Thanks. I had fixed it with padding before but I thought I had done something wrong since the main-nav was the only thing that needed adjusting.

Hi Qasim,

Nothing wrong as such, and in your particular case there was lots of factors affecting the spacing.

You have 3 elements all with potential padding and margin. Line height will play a part in the spacing to.

But its safe to say you have not made any mistakes :)

Craig