Submit Your Article Forum Rules

Results 1 to 3 of 3

Thread: Tableless div problems

  1. #1
    Senior Member
    Join Date
    Feb 2004
    Posts
    216

    Tableless div problems

    Hi All,

    I am new to tabless div development and I have a few questions that maybe you can help me with. Ok, first off how do i render a div below a div that has absolute positioning?

    For example:

    html:

    <div class = "top"> /* text */ </div>
    <div class = "bottom"> /* bottom text */ </div>

    css:

    .top
    {
    position:absolute;
    top: 200px;
    }


    Ok, so I want the bottom div to be rendered underneath the top div. Problem is that it renders it behinf the top div. One way around this would be to set the absolute position of the bottom div to below the top one. Although I will never know how much text is in the top div because the info will come from a dynamic db so i cant give an accurate position to the bottom div.

    Second problem I have is when i have two divs side by side like table layout but i want them to both be the same height.

    for example if i did this:

    <table>
    <tr>
    <td class = "blue"> This side blue </td>
    <td class = "red"> This side red </td>
    </tr>
    </table>

    Ok, so in this situation if i had a load of text in the red td the blue td will also be the same height.

    With two divs set at absolute positions next to each other, when the blue side fills up its height will be longer than the red side. Hence it will look lob sided.

    I may not be explaining this two well but i hope it makes sense.
    Chris.

  2. #2
    WebProWorld MVP
    Join Date
    Aug 2003
    Posts
    1,039
    For question 1 I would not use absolute positioning, but then I never use absolute positioning, instead I would use margin-top: 200px on .top, it should get the same effect depending on the rest of the layout.

    I know this doesn't exactly answer your question, but with an unknown amount of text being present within .top it's the method I would/do use.

    For question 2 http://alistapart.com/articles/fauxcolumns/ explains it quite well, in truth unless you fix the height, the 2 columns really won't be the same height but they will look it and that is all that matters.

  3. #3
    Senior Member bj's Avatar
    Join Date
    Apr 2005
    Posts
    1,171
    Position absolute takes that box out of the flow of the document. This means it will always be on top of whatever else is IN the flow. The flow starts on top and works down. So simply take the position absolute off that div and start your next div- it will automatically go underneath it.

    example--
    .top {
    width: 100%;
    }
    .bottom {
    width: 100%;
    }

    and the html the same way you showed it.

    It's also best cross browser to learn to use float layouts. For info and layouts see Kickass WebGeek CSS Resources.

Similar Threads

  1. OK, I've decided to go tableless... now what?
    By tombstoneweb in forum Graphics & Design Discussion Forum
    Replies: 15
    Last Post: 07-19-2008, 10:59 PM
  2. New tableless site
    By subho in forum Submit Your Site For Review
    Replies: 5
    Last Post: 06-25-2008, 01:53 AM
  3. SEO and tableless design
    By prof611 in forum Search Engine Optimization Forum
    Replies: 69
    Last Post: 12-26-2007, 09:26 AM
  4. SEO and tableless design
    By prof611 in forum Services for Sale/Hire
    Replies: 44
    Last Post: 12-12-2007, 11:38 AM
  5. Help with tableless .css
    By malcolm in forum Graphics & Design Discussion Forum
    Replies: 1
    Last Post: 11-22-2003, 07:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •