16 Replies Latest reply on Feb 3, 2011 2:24 PM by Star Slicer

    How to stretch content div to bottom of page.

    69Pisces

      Been messing around with my site so much that I needed to create a new one.

      However, I can't get to stretch the content div to the bottom of the page if the content text doesn't fill the page.

      I have a footer at the bottom of the page that stretches the full width of the page, so I can't use the trick with the body background.

      I found a lot of results on the internet, but I seem to get a little lost.

      Can anyone help me?

       

      This is my HTML code:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <!-- TemplateBeginEditable name="doctitle" -->
      <title>Schudden fansite</title>
      <!-- TemplateEndEditable -->
      <!-- TemplateBeginEditable name="head" -->
      <!-- TemplateEndEditable -->
      <link href="../css/Noorderzon.css" rel="stylesheet" type="text/css" /></head>

      <body class="oneColElsCtrHdr">

      <div id="container">
      <div id="header">
      <h1> </h1>
      <!-- end #header --></div>
      <div id="mainContent">
      <div id="nav"><a href="#" title="Home">Home</a> | <a href="#" title="Biography">Biography</a> | <a href="#" title="News &amp; Updates">News &amp; Updates</a> | <a href="#" title="Gallery">Gallery</a> | <a href="#" title="Portfolio Work">Portfolio Work</a> | <a href="#" title="Links">Links</a> | <a href="#" title="Contact">Contact</a></div>
      <p>Main Content</p>
      <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. P</p>
          <h2> </h2>
          <p> </p>
      </div>
        <div id="footer">
          <p> </p>
        <!-- end #footer --></div>
      <!-- end #container --></div>
      </body>
      </html>

      And this is the CSS code:

      @charset "utf-8";
      body {
      padding: 0;
      text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
      color: #000000;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 9pt;
      background-color: #800000;
      margin-top: 0;
      margin-right: auto;
      margin-bottom: 0;
      margin-left: auto;
      height: 100%;
      }
      body,td,th {
      font-size: 9pt;
      color: #333;
      }
      /* Tips for Elastic layouts
      1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate.
      2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this.
      3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust based on your final font sizing.
      */
      #container  {
      width: 100%;
      text-align: center; /* this overrides the text-align: center on the body element. */
      margin-top: 0;
      margin-right: auto;
      margin-bottom: 0;
      margin-left: auto;
      background-color: #800000;
      padding-bottom: 0px;
      top: 0px;
      bottom: 0px;
      height: 100%;
      }
      #header  {
      width: 960px;
      padding-top: 0;
      padding-bottom: 0;
      height: 160px;
      margin-right: auto;
      margin-left: auto;
      background-color: #DDDDDD;
      background-image: url(../images/header.jpg);
      }
      #header h1  {
      margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
      padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
      }
      #mainContent  {
      width: 960px;
      margin-right: auto;
      margin-left: auto;
      padding-top: 0;
      padding-right: 0px;
      padding-bottom: 0;
      padding-left: 0px;
      background-image: url(../images/mainbg.jpg);
      height: 100%;
      }

      #nav {
      text-align:center;
      margin-top:0px;
      font-family:Verdana, Arial, Helvetica, sans-serif;
      font-size:10pt;
      color:#000;
      font-weight:700;
      padding-top:9px;
      padding-bottom:10px;
      text-decoration:none;
      background-image: url(../images/mainbg.jpg);
      background-repeat: repeat;
      width: 960px;
      }

      #nav a {
      background:#fff;
      color:#000;
      text-decoration:none;
      }

      #nav a:active {
      background:#fff;
      color:#800000;
      }

      #nav a:hover {
      background:#fff;
      color:#000;
      font-size:10pt;
      padding-bottom:2px;
      border-bottom-width: 3px;
      border-bottom-style: dotted;
      border-bottom-color: #800000;
      }
      a:link {
      color: #000;
      }
      a:hover {
      color: #800000;
      }
      a:active {
      color: #369;
      }


      a:visited {
      color: #369;
      }
      #footer  {
      height: 100px;
      width: 100%;
      padding-top: 0;
      padding-bottom: 0;
      background-image: url(../images/bottom.png);
      margin-bottom: 0px;
      bottom: 0px;
      position: fixed;
      }