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

I don't why I have this margin on top

I have tried everything but still I have this margin on between the h1 and the header. Please take a look at this image to see what I am talking about. Here Website

 <div id="wrapper">
   <header class="header">
       <a href="#logo" class="logo">Logo</a>
       <nav>
         <ul>
            <li><a href="index.html">Home</a></li>
            <li><a href="#portfolio">Portfolio</a></li>
            <li><a href="#About">About</a></li>
            <li><a href="#contact">Contact</a></li>
         </ul>
       </nav>
   </header>

      <section class="heroImg">
           <article>
              <h1>Abraham Swaray</h1>
               <p>Web Developer</p>
           </article>
      </section>
</div>

Css code

/* Default Settings */
* {
  margin: 0;
  list-style: none;
  padding: 0;
  box-sizing: border-box; }

body {
  margin: 0;
  padding: 0; }

/* Wrapper*/
#wrapper {
  margin: 0; }

/*Navigation*/
.header {
  background: #3498db;
  width: 100%;
  height: 60px;
  border-bottom: 2px solid;
  border-radius: 5px;
  margin: 0; }

nav {
  width: 100%;
  color: #fff;
  text-align: right;
  line-height: 50px; }


  nav a {
    color: #fff;
    text-decoration: none;
    padding: 10px; }
    nav a:hover {
      color: #99cbed; }

  nav li {
    display: inline-block;
    line-height: 50px; }

/* Logo*/
.logo {
  float: left;
  line-height: 40px;
  margin-left: 45px;
  color: #fff;
  text-decoration: none; }

/* Hero Image*/
.heroImg {
  background: url("../img/cloudy-mountain.jpg") no-repeat center;
  height: 100vh;
  background-size: 100%; }

.heroImg > h1 {
  margin: 0;
  padding: 0; }

Josh Miclette still not working.

By adding the code and positioning the section image to 'center' 'top', it resolved the issue for me (Chrome and Firefox). How are your stylesheets ordered? Try commenting out your normalize.css and see if that works. If it does, then something is overwriting that code.

What I see

Have you cleared your cache/done a hard refresh?

Can you post the full html file?

7 Answers

Hi Abraham, try this:

/* Hero Image*/
.heroImg {
  background: url("../img/cloudy-mountain.jpg") no-repeat;
  background-position: center top;
  height: 100vh;
  background-size: 100%;
}

I removed 'center' from your 'background' and added a background-position property with the values 'center' and 'top'. The last CSS video I watched, the teacher mentioned adding image positioning to it's own line since it's easier to read. Let me know if that worked.

without access to your source files i'd just be guessing but try these steps.

  1. Check your header's unordered lists margins.

  2. Try inspecting your site using chrome dev tools to find the exact problem.

I'm also not able to reproduce the problem why I just copy and paste your code into Codepen.io

Hi Abraham,

Wasn't able to reproduce the problem on my own computer (in chrome or firefox). But are you using a reset like normalize.css or the Eric Meyer reset? Not using a reset can cause problems like this - where browser default styles are being applied.

I am using normalize.css

Still not working. I am trying to figure it out. I have the normalize.css

Thank you Josh Miclette. I remove the normalize.css and it works perfectly fine.

Glad I was able to help, Abraham.