Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To explain your “bug”:</p> <blockquote> <p>The red and green boxes are set to float to the right and left of the page. Their container does not expand to surround them, and the black and yellow lines touch each other.</p> </blockquote> <p>That’s not a bug, that’s how floats work. Floated elements do not take up vertical space in their ancestor elements. This is because floating was originally designed to enable text to flow around images — if you have a floated image inside a paragraph of text, and it’s taller than the text in that paragraph, you generally want the next paragraph to also flow around the image.</p> <p>To explain how your “fix” works, for your HTML it’s this bit that does it:</p> <pre><code>header:after { clear: both; content: "."; display: block; height: 0; visibility: hidden; } </code></pre> <p>It works thus:</p> <ol> <li><p>The <code>:after</code> pseudo-class effectively adds an anonymous HTML element after the element specified by the rest of the selector (which we’ll call the original element), and allows you to style it. Which is a bit meaningless without...</p></li> <li><p>...the <code>content</code> property. This gives the anonymous element some content, allowing it to affect the layout of the page.</p></li> <li><p><code>display: block</code> and <code>clear: both</code> make this anonymous element clear any floats that come before it (i.e. the floats within the original element). The anonymous element appears after the content box of the original element, but before the padding, border and margin boxes, which is why the clearing pushes the original element’s border down past the floats.</p></li> <li><p><code>height: 0;</code> and <code>visibility: hidden;</code> then make the anonymous element invisible, but don’t prevent it from affecting the page’s layout.</p></li> </ol> <p>Your “fix” repeats this CSS for <code>div:after</code>, <code>article:after</code> and <code>aside:after</code>. I’m not sure why it doesn’t just use all three selectors together on one CSS rule, i.e.</p> <pre><code>header:after, article:after, aside:after, div:after { /* Fix CSS here */ } </code></pre> <p>Or indeed apply the CSS to a class instead of elements, so that you can choose when to apply it, e.g.</p> <pre><code>clear-floats:after { /* Fix CSS here */ } </code></pre>
    singulars
    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.
    2. VO
      singulars
      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