Reputation: 2636
I am building a page using blocks of sections: http://jsfiddle.net/NrkTn/3/
You can see I have added margin to the section elements, however I'm unable to add both top and bottom margins, it uses whichever is the largest value.
Each section should have a top and bottom margin of 20px, making the space between them 40px, however it is showing a margin of only 20px.
Upvotes: 0
Views: 51
Reputation: 2566
Margins collaspe on themselves, so that is expected behavior. You could do what you want by changing your section CSS to use borders instead
#page section{ border-top: 20px solid white; border-bottom: 20px solid white; }
Another way to do what you want is to wrap your sections in divs and use padding
Upvotes: 0
Reputation: 10391
That is expected behavior. It will always take the largest margin and not a combination of the two. Here's an article that explains this.
Upvotes: 0