Results 1 to 6 of 6

Thread: 100% hight div w/ hight:auto parent?

  1. #1
    Join Date
    Jan 2009

    Question 100% hight div w/ hight:auto parent?

    Hi all! I'm trying hard not to use tables, but can't figure out how to do this w/ box modeling. I would like a div that is auto hight so that it stretches to accommodate the contents. Inside that div I need 3 divs, left column (auto height), right column (auto height), and a divider in the middle which is like a middle column. That middle divider needs to be 100% height of the parent div so that it stretches w/ it. Kind of like a table, you know.

    I can't figure out how to do this. Everything I find on google tells me that for a div to be 100% height, height needs to be specified, either in percent or pixels on the parent div and all the way up to body/html. But I can't have that, the parent div needs to stretch and can't have a minimum height.

    Here's my mini-example code. As you can see the middle/divider column's got a non-existant height.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            <title>Test Div Stretch</title>
            <style type="text/css">
                #clearBoth {clear: both; visibility: hidden;}
                .container {border: 1px blue solid;}
                .col { float:left; border: 1px solid red; width: 300px;}
                .divider { width: 3px; height: 100%; background: green;}
            <div class="container">
                <div id="leftCol" class="col">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</div>
                <div id="midCol" class="col divider"></div>
                <div id="rightCol" class="col">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed</div>
                <div id="clearBoth"></div>
    I'm almost ready to resort to tables.
    Any ideas?


  2. #2
    Join Date
    Aug 2010
    set parent div to overflow: hidden, then in child divs you can set padding-bottom: 5000px margin-bottom: -5000px and then all child divs will be the height of the parent. Of course this wont work if you are trying to put content in the parent div (outside of other divs that is)

  3. #3
    Join Date
    Jan 2009
    Is this the only way to do this? What happens if the parent div grows to be more then 5000px hight? It might do that, because in my app one of the columns could contain an actual essay, it can span multiple printed pages. Setting an actual max height is not a good idea.

  4. #4
    Join Date
    Oct 2010
    Thats how I would do it personally, but can I ask why if your divider is just a 3px wide with a background... why dont you just use
    #leftCol {
       border-right: 3px solid green;

  5. #5
    Join Date
    Jan 2009
    There's 2 reasons:
    The code I posted just used a plane color because it's a simple example, I was originally going to use an image (gradient). The document should conform to CSS 2 specifications, so I can't use the CSS 3 image border thing.

    The 2nd reason is this: even if I were to just give up on the gradient divider and use solid color, which column's border should I use? If I use the right column's border, what if the left column is longer? Then the border won't stretch all the way down and will only go the length of the right column. And vice versa. If I use both column's border it's going to be 1/2 width for a segment where one column is longer then the other.

    I also can't use javascript to figure out which column is longer, because FlyingSaucer PDF generator does not evaluate javascript, it just does HTML and CSS 2.

    Is there a way I can use display: table properties somehow for this? I tried and they didn't do anything, but maybe I was doing it wrong or something.

  6. #6
    Join Date
    Jan 2009
    *Sigh* looks like no box modeling for me.

    /me goes to replace divs w/ tr/tds

    Thanks guys!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.10555 seconds
  • Memory Usage 2,893KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates