#1
  1. PHP user-in-training
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2001
    Location
    Sacramento Calif. USA
    Posts
    677
    Rep Power
    0

    Trying to put two boxes inside a thrid box with CSS. But outside will not autosize.


    Here is the code of what I am attempting:

    PHP Code:
    #outside_box {
        
    positionrelative;
        
    width100%;
        
    font18px Verdanasans-serif;
        
    color#777777;
        
    padding0px;
        
    border1px solid #999999;
        
    margin-bottom5px;
        
    backgroundtransparent;
        }

    #inside_box_left {
        
    positionabsolute;
        
    width70%;
        
    left:0;
        
    padding0px;
        
    border0px solid #999999;
        
    margin0px;
        
    backgroundlightgrey;
        }
    #inside_box_right {
        
    positionabsolute;
        
    width30%;
        
    right:0;
        
    padding0px;
        
    border0px solid #999999;
        
    margin0px;
        
    backgroundlightgrey;
        }



    <
    div id="outside_box">

        <
    div id="inside_box_left">
    text left box
        
    </div>

        <
    div id="inside_box_right">
    text right box
        
    </div>

    </
    div
    The two inside boxes form correctly, but the outside box does not correctly adjust to contain the inside boxes.

    I know I have read something about what I am missing here, so am hoping someone can give me a pointer.

    Thanks for any help.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2002
    Location
    Queensland, Australia
    Posts
    827
    Rep Power
    142
    I believe this page has your answer

    http://www.alistapart.com/stories/practicalcss/
  4. #3
  5. PHP user-in-training
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2001
    Location
    Sacramento Calif. USA
    Posts
    677
    Rep Power
    0
    Yes it may, thanks for the reference.
  6. #4
  7. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    151
    Rep Power
    0
    seems fine to me. the outside box is 100%, with the inners adding up to 100% too. what are you trying to do?
  8. #5
  9. PHP user-in-training
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2001
    Location
    Sacramento Calif. USA
    Posts
    677
    Rep Power
    0

    Unhappy


    Well the problem with the CSS examples given, is that they will not fill up their respective side of the outside box.

    So for example, if I want to have two boxes next to each other, as you might have two table cells. And I want the left box to be some form entry description, and the right box to be the form text entry cell - If the text is long the box on the left will expand correctly(3 lines), but the background of the box on the right(1 line), will only extend to the vertical height of the 1 line.

    Now if you used two table cells and not css, you could have each cells color defined, and not worry about the left cell being 3 times as high as the cell on the right, and thus affected the right cells background color.

    Hope that makes sense.
  10. #6
  11. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    151
    Rep Power
    0
    Oh, ok. then set the height of the inner boxes to 100%
  12. #7
  13. PHP user-in-training
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2001
    Location
    Sacramento Calif. USA
    Posts
    677
    Rep Power
    0
    Yes, tried that and still no luck, the rightside box still wants to only cover 1 line height for some reason.

    here is what the CSS looks like:

    PHP Code:
    #inside_box_left {
        
    floatleft;
        
    padding-left10px;
        
    width70%;
        
    height100%;
        
    left:0;
        
    padding0px;
        
    border0px solid #999999;
        
    margin-left0px;
        
    backgroundlightgrey;
        }
    #inside_box_right {
        
    floatright;
        
    padding-right10px;
        
    width30%;
        
    height100%;
        
    right:0;
        
    padding0px;
        
    border0px solid #999999;
        
    margin-right0px;
        
    background#999999;
        

  14. #8
  15. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    151
    Rep Power
    0
    oh. you must set the outer box to have a height. then it will work.
  16. #9
  17. PHP user-in-training
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2001
    Location
    Sacramento Calif. USA
    Posts
    677
    Rep Power
    0
    Ahhh, that got it. Thanks

  18. #10
  19. PHP user-in-training
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2001
    Location
    Sacramento Calif. USA
    Posts
    677
    Rep Power
    0
    hah.

    Ok one more question.

    I have a checkbox in the right-side box, is there a way to vertically align it?

    I tried

    vertical-align:middle;

    and

    vertical-align:text-middle;

    but had no success.

    Since it is a form object, not sure how to deal with it.

IMN logo majestic logo threadwatch logo seochat tools logo