Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Senior Member Blackhawk095's Avatar
    Join Date
    May 2011
    Location
    Kentucky (USA)
    Posts
    384
    Member #
    27969
    Liked
    45 times
    In the website I'm building, I'm having trouble with two divs (#content_container and #content_main).

    #content_container is the light grey in the background of the content area.

    #content_main is the white div with the 1px border.

    When I set the height in #content_container to (height: auto), the whole div collapses. It is supposed to wrap around the #content_main div with 10px of padding on the top and bottom.

    At this point, the design should look like this:



    but instead, it looks like this:



    Here is the HTML and CSS I used:

    HTML:
    HTML Code:
        <div id="content_container">
            <div id="content_main">
                <div id="welcome_to_soa_bg">
                    <div id="welcome_to_soa_head"></div>
                    <div id="welcome_to_soa_sub_head_text">We are now recruiting Modern Warefare 3 gamers!</div>
                    <div id="welcome_to_soa_green_sub_head">We are looking for players that match the following requirments:</div>
                    <div id="welcome_to_soa_list">
                        <ul>
                            <li>Muture players at least 16yrs old</li>
                            <li>Must have a mic</li>
                            <li>Must be active on clan forums, website, and games</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    CSS:
    Code:
    div#content_container {
        width: 980px;
        height: 235px;
        background-color: #f4f4f4;
        padding: 10px;
    }
    
    div#content_main {
        width: 725px;
        height: auto;
        background-color: #fafafa;
        border: 1px solid #e1e1e1;
        float: left;
        padding-top: 10px;
        padding-left: 5px;
        padding-right: 5px;
        padding-bottom: 10px;
    }
    Do you guys see anything wrong?

    By the way, if it helps, here is a screenshot of what the finished design should look like:
    http://www.my-testing-area2.netau.ne...late_final.png

    and here is the coded version of what I have so far:

    http://www.my-testing-area2.netau.ne...rs_of_america/
    [COLOR=rgb(0, 51, 102)]Student Web Designer[/COLOR]
    [COLOR=rgb(0, 51, 102)]If you thought something I said was helpful. LIKE IT![/COLOR]

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    I got it to work by setting display:inline-block and height:auto in Chrome.

    You could also just set a min-height.
    Blackhawk095 likes this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Senior Member Blackhawk095's Avatar
    Join Date
    May 2011
    Location
    Kentucky (USA)
    Posts
    384
    Member #
    27969
    Liked
    45 times
    Quote Originally Posted by Ronald Roe, post: 226146
    I got it to work by setting display:inline-block and height:auto in Chrome.

    You could also just set a min-height.
    It worked. I have no idea how adding [ display: inline-block ] fixed it, but at least that problem is resolved.
    [COLOR=rgb(0, 51, 102)]Student Web Designer[/COLOR]
    [COLOR=rgb(0, 51, 102)]If you thought something I said was helpful. LIKE IT![/COLOR]

  5. #4
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    It's the same old float issue. For some reason, divs that contain floated elements won't stretch to fit their floated contents. There's a number of "hacks" to overcome that. Another way to fix it is the old clearfix hack.

    You put this in the same container after the floated elements:
    <div class="clearfix"></div>

    Then, this in your CSS:
    .clearfix{
    clear:both;
    height:0;
    overflow:hidden;
    width:100%;
    }

    That's actually probably the preferred method, since display:inline-block doesn't work in all browsers.
    Blackhawk095 likes this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  6. #5
    Senior Member Blackhawk095's Avatar
    Join Date
    May 2011
    Location
    Kentucky (USA)
    Posts
    384
    Member #
    27969
    Liked
    45 times
    Thanks for taking the time to explain how to fix that issue. It will help a lot in the future.
    Ronald Roe and AlphaMare like this.
    [COLOR=rgb(0, 51, 102)]Student Web Designer[/COLOR]
    [COLOR=rgb(0, 51, 102)]If you thought something I said was helpful. LIKE IT![/COLOR]

  7. #6
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    No problem
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  8. #7
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    I'm tend to add overflow: hidden; to the parent where I can in this sort of instance. It does mean you can't have like relative/absolutely positioned overflowing sort of items though - but this is rarely an issue, and neatens up the html a bit.

    The site's looking good!
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:24 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com