Jump to content

css sticky footer main div height


arbitter

Recommended Posts

Hi there.

 

The title might be somewhat confusing, but here's the explanation. My site consists of the following layout:

  • Header
  • Left sidebar
  • Main content
  • Footer

 

This I've got working nicely with the following code:

HTML:

<html>
   <body>
      <div id='total'>
         <div id='wrap'>
            <div id='banner'></div>
            <div id='main'>
               <div id='sidebar'>
                  <div class='menuoption'></div>
                  <div class='menuoption'></div>
                  <div class='menuoption'></div>
                  <div id='leftFill'></div>
               </div>
               <div id='content'>Variable content over here</div>
            </div>
         </div>
         <div id='footer'></div>
      </div>
   </body>
</html>

And the css:

html{height:100%;}
body{
   margin:0 0 0 0;
   height:100%;
}
#total{
   width:1024px;
   margin:auto;
   height:100%;
}
#wrap{
   min-height:100%;
}
#main{
   overflow:auto;
   padding-bottom:28px;   /* Height of footer */
}
#header{
   height:100px;
   background-color:purple;
}
#sidebar{
   width:149px;
   float:left;
   height:100%;
}
#content{
   width:794px;
   float:left;
   min-height:600px;
}
#footer{
   height:28px;
   margin-top: -28px;
   clear:both;
   position:relative;
}

 

So what's happening: the footer should always be at the bottom of the page, as long as the content inside #content is not larger than the height of the page. Otherwise, the footer goes to the foot of the document.

 

Now the trouble is; I would like the #leftFill to have  a border on the right side. But this bordershoul go from the last 'menuoption' down, up to the footer, wherever the footer is. How is this done?

Link to comment
Share on other sites

Instead

You can float both sidebar and content divs left, removing the min-height,

then apply a clearfix on the footer

 

Maybe then re-apply the leftFill height of 100%

They are both already floated left, and there is 'clear:both' in the footer already...
Link to comment
Share on other sites

played around with and go sourted replace your code with this one.

 

 <div id='total'>
         <div id='wrap'>
            <div id='banner'></div>
            <div id='main'>
               <div id='sidebar'>
                  <div class='menuoption'>gggg</div>
                  <div class='menuoption'>hhhh</div>
                  <div class='menuoption'></div>
                  <div id='leftFill'></div>
               </div>
               <div id='content'>
                 <p>Variable content over herei</p>
                 <p> </p>
                 <p> </p>
                 <p> </p>
                 <p> </p>
               </div>
               <div style="clear:both";></div>
            </div>
         </div>
         <div id='footer'></div>
      </div>

 

 

html{height:100%;}
body{
   margin:0 0 0 0;
   height:100%;
}
#total{
   width:1024px;
   margin:auto;
   height:100%;
}
#wrap{
   
}
#main{
   overflow:auto;
   padding-bottom:28px;   /* Height of footer */
}
#header{
   height:100px;
   background-color:purple;
}
#sidebar{
   width:149px;
   float:left;
   height:100%;
}
#content{
   width:794px;
   float:left;
   min-height:60%;
}
#footer{
   height:28px;
   margin-top: 2px;
   clear:both;
   position:relative;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.