Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>the background colour only goes one screen height down then ends and I cant seem to figure out why!</p> </blockquote> <p>Here's why: </p> <pre><code>body { height:100%; } html { height: 100%; } </code></pre> <p>Ask yourself: 100% of <em>what?</em> The answer is <em>not</em> 100% of the content. Percentage heights always refer to a percentage of the height of the <em>parent</em> element. Since you have not set any explicit heights (in pixels), the browser uses the height of the <em>viewport</em> and calculates the height <code>body</code> to be 100% of that. </p> <p>The <em>viewport</em> is the viewable area inside your browser. Since your content extends below this area (i.e., you have to scroll down to see it all), it ends up outside the <code>body</code> and therefore outside the background color set on the <code>body</code>.</p> <p>If you don't specify a height for <code>html</code> or <code>body</code>, they will only be as tall as the content, but the background for <code>html</code> will still fill the viewport.</p> <p>So the solution is this:</p> <pre><code>html { height:100%; /* sets html to height of viewport (bg color will still cover viewport) */ } body { /* don't set explicit height */ min-height:100%; /* expands body to height of html, but allows it to expand further if content is taller than viewport */ } </code></pre> <p>You don't need any additional content elements; the <code>body</code> behaves like any other element. Only <code>html</code> is a bit different since its background-color will cover the whole viewport even if the calculated height is different from the viewport or any child elements.</p> <p>You may need some hacks to handle older browsers that don't understand min-height.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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