Anonymous 0

Hey there,

I'm working on a vertical page layout that has a couple of divs positioned under each other, between them I have a div that defines the amount of space to leave between each div.

Problem is, the divs are leaving their own little space under themselves!

How do I get rid of this?

2 answers

This was chosen as the best answer

Without seeing the code it's difficult to understand the problem and hence suggest a solution, but if you have content within the divs, it may be that you have a margin-collapse issue - where margins on enclosed content, stick out through the container and affect other page elements.

try adding padding to the top and bottom of the divs and see if that solves the problem.

read about margin-collapse here;

Answered over 8 years ago by Tony Crockford

The space outside the div is set by setting the margin and the space inside the div border between the border and the content is set using the padding setting.

use your one div id name or class id

#divid {margin:0px;}


#divid {margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;}

That should do it.

Answered over 8 years ago by Steve Massing
  • no luck, still giving the same result! :( Troy over 8 years ago
  • actually, it displays correctly in dreamweaver now, but not in Safari Troy over 8 years ago
  • You should also check the padding on the div and margins on any enclosed tags like <p> (See Troy's link above) Steve Massing over 8 years ago