Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure I completely understand the question, but I'll take a stab at it:</p> <p>I don't believe that there is a time where a float will collapse a margin. I've looked at your code and I don't see any margin set in the css that then is 'collapsed' when I view it in a browser (I'm using Safari).</p> <p>Here's my thoughts:</p> <p>In the first part of your example, you have the normal flow div before the floated div. The floated div will just be rendered below the normal flow div.</p> <p>In the second part of your example you have the floatedRect divs above the normal flow divs. That's when you see the text move to the right. This is not affecting the margin of the text divs or collapsing the margins. It is just allowing the text to 'float' around the floatedRect divs. I've changed your code to illustrate:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;Inheritance Tests&lt;/title&gt; &lt;style&gt; * { margin: 0px ; padding: 0px ; font-family: courier ; font-size: small ; } .test4 {width: 400px; height: 100px; border-style: solid; border-width: 1px;} .test5 {border: 1px solid red; width: 200px; height: 50px; float: left; margin:10px; } .floatedRect { width: 50px ; height: 50px ; float: left ; background-color: #9cf ; } .text { margin: 10px; border:1px solid red; position:relative; z-index:1; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="test5"&gt; Floated &lt;/div&gt; &lt;div class="test4"&gt; Normal Flow &lt;/div&gt; &lt;div style="margin-top: 100px"&gt; Has a top margin &lt;/div&gt; &lt;div style="clear: both"&gt; &lt;div class="floatedRect"&gt;&lt;/div&gt; &lt;div class="text"&gt;some text&lt;/div&gt; &lt;div class="floatedRect"&gt;&lt;/div&gt; &lt;div class="text"&gt;some text&lt;/div&gt; &lt;div class="floatedRect"&gt;&lt;/div&gt; &lt;div class="text"&gt;some text&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p></p> <p>Notice that the text divs have a 10px margin still, but the text has been pushed to the right by the floatedRect divs.</p> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload