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

Issues with margins on my divs

Hey guys,

I am building a portfolio page where I have static navigation on the left side and various information containers along the right side. However the containers that have information are displaying with spaces in between. See the link below:

http://almontas.github.io/Portfolio/

I am building this site from scratch to make it look something like this:

http://html5up.net/prologue

Any help will be appreciated!

3 Answers

1) How were you able to trouble-shoot?

I used a Firefox add-on called Firebug to check the code and edit it live. You can also use Firefox's or Chrome's built-in developer tools. There's probably a section somewhere here that teaches you how to use them.

2) Now I have spacing between the sections of the #main div and the #body of the div as well as the footer? Any suggestions?

You have padding in your #main div that's affecting the spacing on the top and bottom of that div. Try changing your code to look like this:

#main {
    padding: 0;
}

Your h2 tags have margin that is causing the spaces between the posts. If you remove their margin and replace it with padding, you won't have the spacing issue anymore.

Your new h2 code would look something like this:

h2 {
    font-size: 2em;
    letter-spacing: -1px;
    margin: 0; /*margin is removed, spacing between sections goes away*/
    padding: 20px; /*padding is added to create spacing between h2 and other content*/
}

Vlatko Mojsoski thank you that did most of the trip...a couple of questions:

1) How were you able to trouble-shoot?

2) Now I have spacing between the sections of the #main div and the #body of the div as well as the footer? Any suggestions?

Thanks,

AM.