CSS Odd Behavior: min-height and margin collapse -


consider following code:

.container {    min-height: 100px;    background-color: lightgreen;  }    p {    margin-bottom: 50px;  }
<div class="container">      <p>welcome</p>  </div>  <div class="after">    main content.  </div>

http://jsfiddle.net/lp4tp/31/

question:

mdn's margin collapse page states if there min-height set on parent element, prevent bottom margin adjoining last child's bottom margin - prevent margin collapsing. me, makes sense.

parent , first/last child:
if there no border, padding, inline part, block_formatting_context created or clearance separate margin-top of block margin-top of first child block, or no border, padding, inline content, height, min-height, or max-height separate margin-bottom of block margin-bottom of last child, margins collapse. collapsed margin ends outside parent.

in example, however, devtools shows bottom margin of p tag expected - directly beneath p element - there 50px of blank space below container, doesn't make sense. margin of p tag seems still collapsing somehow, ending outside parent , affecting position of next element, though margin of p , .container not adjoining, , devtools shows p tag's margin near bottom of .container.

anyone have explanations why margin still sort of collapsing , leaving blank space below .container? also, mdn page wrong in saying min-height prevent margin collapse?

thanks


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -