+ Reply to Thread
Results 1 to 4 of 4

Thread: CSS div height - auto doesn't go to end and absolute wrecks footer position

  1. #1
    as4s1n's Avatar
    as4s1n is offline x10 Sophmore as4s1n is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Washington State
    Posts
    174

    CSS div height - auto doesn't go to end and absolute wrecks footer position

    On my website I have a right column that, if someone is logged in, shows their recent posts. However, the auto setting doesn't go to the end of page, which is what I would like, and if I set it to absolute then the footer with the 'clear:both' property makes it hover just after the right column ends. I was sure that the auto works if the div it is inside has an absolute height, but if I set that then the page goes out of order when someone tries to post a new entry.

    CSS:
    Code:
    div#content-wrapper 
    {
     width:80%;
     float:left;
    }
    div#right 
    {
     width:20%;
     float:right;
     min-height:300px;
    }
    div#right-inner 
    {
     border-left: 5px solid black;
    }
    div#footer 
    {
     clear:both;
     text-align:center;
    }
    HTML (for HTML view source code)

    Example: http://sikuneh.x10hosting.com

    Note: Please ignore posts, those are just tests.
    Last edited by as4s1n; 04-16-2010 at 12:02 PM.
    There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: CSS div height - auto doesn't go to end and absolute wrecks footer position

    Do you have a picture illustrating the affect you want? Do you want the right column to stretch down to the footer, or end at the viewport? Will the right column have a background? If not, you could simply give the left column a right border, rather than giving the right column a left border.

    A web search for "two column layout" should turn up various methods of achieving what you want.
    Last edited by misson; 04-16-2010 at 01:15 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    as4s1n's Avatar
    as4s1n is offline x10 Sophmore as4s1n is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Washington State
    Posts
    174

    Re: CSS div height - auto doesn't go to end and absolute wrecks footer position

    My plan was to get the border to go to the footer but since I use relative width attributes (%s) and I use a 5 px border it puts the right column down below the left column and when I lower the left/right column width then there is a gap between the two that doesn't look quite right. Should I just change to absolute positioning or is there another solution?
    There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: CSS div height - auto doesn't go to end and absolute wrecks footer position

    Quote Originally Posted by as4s1n View Post
    Should I just change to absolute positioning or is there another solution?
    Absolute positioning will just introduce more problems.

    Rather than trying to get the right column to stretch to the footer, put the border on the main content, but as a child of the left column element so it doesn't mess up your relative widths.

    HTML Code:
    <style type="text/css">
        #MainCol {
            float: left;
            width: 80%;
        }
        #SideCol {
            float: right;
            width: 20%;
        }
        #MainContent {
            border: 5px solid black;
        }
        ...
    </style>
    </head>
    <body>
      <div id="Header">...</div>
      <div id="Torso">
          <div id="MainCol">
              <div id="MainContent">
                ...
              </div>
          </div>
          <div id="SideCol"></div>
      </div>
      <div id="Footer">...</div>
    You could also try negative margins on #MainCol equal in size to the border width, but not all browsers handle negative margins the same way.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Expand div height to fit parent
    By diabolo in forum Programming Help
    Replies: 2
    Last Post: 12-21-2009, 09:35 PM
  2. 100% height with CSS
    By Ixonal in forum Graphics & Webdesign
    Replies: 11
    Last Post: 03-08-2009, 06:28 PM
  3. Line-Height?
    By Twinkie in forum Programming Help
    Replies: 4
    Last Post: 02-21-2009, 11:27 PM
  4. Getting a Div to stretch the whole height of a page
    By Zenax in forum Scripts & 3rd Party Apps
    Replies: 5
    Last Post: 12-10-2006, 10:16 AM
  5. How to control table height
    By clareto in forum Scripts & 3rd Party Apps
    Replies: 4
    Last Post: 11-26-2005, 10:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers