Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Fix Collapsing Top and Bottom Margins?

Tags:

css

margin

I'm new to CSS and I'm trying to understand how to fix the following line from not working for top and bottom margins. It works for side margins just fine, however:

.contents {
    ...
    margin: 10px 10px 10px 10px;
}

Example: http://jsfiddle.net/LCTeU/

How do I fix this?

Edit:

I've also tried padding the container instead, and that just expands the container to maximum size (why?):

.container {
    ...
    padding: 10px 10px 10px 10px;
}
like image 309
Mike Holler Avatar asked Nov 30 '25 11:11

Mike Holler


1 Answers

Use overflow:auto on any of the elements that are involved with the collapse. For example:

article {
    overflow:auto;
}

jsFiddle example

like image 105
j08691 Avatar answered Dec 03 '25 01:12

j08691



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!