treehouse : what would you like to learn today?
Web Design Web Development iOS Development

100% Expanding footer (non sticky footer)

  • Hello all,

    I am having trouble with a footer expanding. I know what your thinking, just look up sticky footers. Well I don't want sticky footers, I want the footer to expand 100% if the browser res is larger than the page. Here is and example of what its is doing: [attachment=0]site.gif[/attachment] Basically I want that grey area to expand to the bottom on larger screens.

    Any ideas? Very simple CSS for the footer

    div.footer {
    background:#E1E7E7;
    height:100%;
    }
    /* THIS IS INSIDE THE FOOTER */
    div.footer-container {
    position:relative;
    width:826px;
    margin:0px auto 0 auto;
    }
    div.footer-container ul {
    height:200px;
    }
    /* THIS IS FLOATING ELEMENT - I DON'T THINK IT IS THE PROBLEM AS DISPLAY:NONE; DOES NOT EFFECT THE PROBLEM I\"M HAVING */
    div.flash-beaker {
    position:absolute;
    margin-top:-147px;
    margin-left:718px;
    }
  • I just tried

    body, html {
    height: 100%;
    }

    and it worked, but now I have extra space on the scrollbar. Hummm
  • I tried to separate the code so you could see what I'm talking about...Also here is a new screen. notice the scrollbar on the right. This is driving me nuts.[attachment=0]site-long.gif[/attachment]

    CSS
    html, body {
    height: 100%;
    }

    div.site-container {
    width:826px;
    margin:0 auto 0 auto;
    overflow:hidden;
    }
    div.header {
    overflow:hidden;
    }

    div.sidebar {
    width:225px;
    float:left;
    overflow: hidden;
    }
    div.news-updates-scroller {
    height:311px;
    overflow:auto;
    }
    div.right-content-well {
    float:right;
    overflow:hidden;
    }
    div.footer {
    background: #999999;
    min-height:100%;
    }
    div.footer-container {
    width:826px;
    margin:0 auto 0 auto;
    }

    HTML

    <div class=\"site-container\">
    <div class=\"header\"><a href=\"#\"><img class=\"logo\" src=\"/images/logo.gif\"></a>
    <ul>
    <li><a href=\"#\">About Us</a></li>
    <li><a href=\"#\">Portfolio</a></li>
    <li><a href=\"#\">Contact</a></li>
    <li class=\"nav-log-in\"><a href=\"#\">Log In</a></li>
    </ul>
    </div>
    <!--END HEADER -->
    <div class=\"sidebar\">
    <?php include (TEMPLATEPATH . \"/searchform.php\"); ?>
    <div class=\"sidebar-accordian\"> <a class=\"accordian-heading\">blah</a>
    <div> Blah Blah</div>
    <a class=\"accordian-heading\">blah</a>
    <div> Blah Blah</div>
    <a class=\"accordian-heading\">blah</a>
    <div> Blah Blah</div>
    </div>
    <!-- END SIDEBAR ACCORDIAN -->
    <div class=\"sidebar-news-updates\"> <a href=\"#\" class=\"news-updates-heading\">News &amp; Updates</a>
    <div class=\"news-updates-scroller\"> </div>
    <!-- END NEWS UPDATES SCROLLER -->
    </div>
    <!-- END SIDEBAR NEWS UPDATES -->
    </div>
    <!-- END HOME SIDEBAR -->
    <div class=\"right-content-well\"> <img src=\"/images/home-flash-demo.jpg\" alt=\"flash-demo\" />
    <div class=\"main-content-section\">
    <h3>Latest Projects</h3>
    </div>
    <!-- END MAIN CONTENT SECTION -->
    <div class=\"client-list\">Client List</div>
    <!-- END CLIENT LIST -->
    </div>
    <!-- END RIGHT CONTENT WELL -->
    </div>
    <!-- END SITE CONTAINER -->
    <div class=\"footer\">
    <div class=\"footer-container\">
    <div class=\"flash-beaker\"> </div>
    <!-- END FLASH BEAKER -->
    <div class=\"footer-content\">
    <ul>
    <li><a href=\"#\">About Us</a></li>
    <li><a href=\"#\">Portfolio</a></li>
    <li><a href=\"#\">Contact</a></li>
    </ul>
    </div>
    <!-- END FOOTER CONTENT -->
    </div>
    <!-- END FOOTER CONTAINER -->
    </div>
    <!-- END FOOTER -->
    </div>
    <!-- END SITE CONTAINER -->
    <div class=\"footer\">
    <div class=\"footer-container\">
    <div class=\"flash-beaker\">
    <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"179\" height=\"292\">
    <param name=\"movie\" value=\"<?php bloginfo('template_directory'); ?>/images/beaker_anim.swf\" />
    <param name=\"quality\" value=\"high\" />
    <embed src=\"<?php bloginfo('template_directory'); ?>/images/beaker_anim.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"179\" height=\"292\"></embed>
    </object>
    </div>
    <!-- END FLASH BEAKER -->
    <div class=\"footer-content\">
    <ul>
    <li><a href=\"#\">About Us</a></li>
    <li><a href=\"#\">Portfolio</a></li>
    <li><a href=\"#\">Contact</a></li>
    </ul>
    &copy; All rights reserved.</div>
    <!-- END FOOTER CONTENT -->
    </div>
    <!-- END FOOTER CONTAINER -->
    </div>
    <!-- END FOOTER -->
    <?php wp_footer(); ?>
    </body></html>
  • Let me make sure I'm understanding your question. You have a footer that starts out at height X. If the browser window is smaller than the page (or the same size), then the footer's height stays at X. But if the browser window is larger than the page, rather than having the footer keep its height of X and move so that it sticks to the bottom, you want it to stay in the same position but get taller so that it touches the bottom of the window?

    Assuming that's correct, I feel like you'd have to use some JavaScript to accomplish that, because the height of the footer would be dependent upon the height of the window. Use JS to grab the height of your page's container and the height of the browser window. Then, subtract the container's height from the window's height, and add that difference onto the footer.

    Alternatively, if your footer is just a solid color...just make your page's background the same color! Then when the footer ends, it'll blend right in with the page background, making it look like the effect you want.
  • Hey daGUY,

    Thanks for the reply. I was afraid I was going to have to revert to JS. The solution I am currently using works, but for some reason makes the scrollbar acts a bit strange. It fills in the blank space, but ends up adding extra space at the bottom for some reason. Check out the second screen for details.

    I wish I could use your second option, but I have two backgrounds across the page. Maybe I could rework the top HTML to give me the effect your talking about. You gave me a new idea so I'll see what I can do...