CSS positioning problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sooshi
    New Member
    • Feb 2008
    • 4

    CSS positioning problem

    Hi all,

    The height of my page needs to be flexible as the page contains columns with lists which can vary in length. I also have a footer which needs to be stuck to the bottom.

    I managed to do all of the above. My problem now is the positioning of the columns. With relative positioning, the columns appear staggered with column2 starting lower than column1.

    If I use {float:left}, the two columns stay next to each other which is good but then the footer brings itself up and overlaps with the columns... I don't know if I am clear with my explanation so here is my code. Thanks in advance!


    HTML:[html]
    <html>
    <body>
    <div id="container-page">
    <div id="container-content">
    <div id="container-columns">
    <div id="col1">
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    </div>
    <div id="col2">
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    <li>list</li>
    </div>
    </div >
    </div >
    <div id="container-foot">footer</div >
    </div>
    </body>
    </html>
    [/html]
    [code=css]
    <style type="text/css">
    <!--
    #container-page {
    left:50%;
    margin-left:-381px;
    width: 762px;
    position: relative;
    top:0px;
    min-height: 100%;
    height: auto;
    height: 100%;
    }

    #container-content {
    padding-bottom: 20px;
    }

    #container-foot {
    width: 760px;
    height: 20px;
    position: absolute;
    bottom: 0;
    bottom: -1px;
    }

    #container-columns {
    width:760px;
    top: 0px;
    position:relati ve;
    display:block;
    }

    #col1 {
    position: relative;
    top: 0px;
    left: 1px;
    width: 234px;
    padding-bottom:40px;
    background-color:#cccccc;
    }

    #col2 {
    position: relative;
    top: 0px;
    left: 262px;
    width: 234px;
    padding-bottom:40px;
    background-color:#cc0000;
    }
    -->
    </style>[/code]
    Last edited by drhowarddrfine; Feb 16 '08, 02:17 PM. Reason: Please use code tags
  • just a feeling
    New Member
    • Aug 2007
    • 86

    #2
    Hi sooshi,

    use float:left and remove the position:absolu te style from #container-foot. Kindly, early and often test ur pages through
    HTML validator
    CSS validator

    Good Luck.

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      And use a proper doctype.

      Comment

      • sooshi
        New Member
        • Feb 2008
        • 4

        #4
        It works! Thanks guys!

        Comment

        • sooshi
          New Member
          • Feb 2008
          • 4

          #5
          I have another urgent question concerning the same layout.

          (http://cie7273.com/test/test.html)

          The column with lists is not correctly aligned horizontally under IE 7. It should be aligned left with the rest of the layout. Instead, it appears a few pixels to the right.

          Can anyone tell me what I'm doing wrong?

          Thanks in advance

          Comment

          • drhowarddrfine
            Recognized Expert Expert
            • Sep 2006
            • 7434

            #6
            An 'id' is a unique name assigned to only one element on a page. Validate your html for that list of errors, then validate your css for the error there.

            If those don't work, add margin:0 and padding:0 to the lists and/or containers.

            What's with all the divs around the list?

            Comment

            • sooshi
              New Member
              • Feb 2008
              • 4

              #7
              Thanks for that. Unfortunately, it doesn't seem to do the trick.

              Comment

              Working...