www.webdeveloper.com
Results 1 to 5 of 5

Thread: Auto expand div height to children divs

  1. #1
    Join Date
    Jun 2006
    Location
    Boston, MA
    Posts
    383

    Auto expand div height to children divs

    Hey Guys,

    so.. i have 1 parent DIV and about 10 child DIVs displayed vertically. I can't quite figure out how to work this the way i want it.

    I set the parent DIV height to auto to expand, as the children DIVs heights differ, BUT I want to cut of the expand at 5 child DIVs and hide the rest using overflow.

    I've tried setting the height of the parent DIV, but then one of the 5 child DIVs gets cut of in the middle by the hidden overflow, so i want to expand it to the end of the 5th child.

    any ideas?
    "Problems cannot be solved by the same level of thinking that created them.

  2. #2
    Join Date
    Jul 2006
    Posts
    207
    Have you tried setting a max-height on the parent DIV? You have to keep changing the pixels till' all 5 DIVs fit.

  3. #3
    Join Date
    Jun 2006
    Location
    Boston, MA
    Posts
    383
    that i've tried. the problem though, is that these divs heights differ depending on the content dynamically randomly placed in there..

    so there are 10 product boxes(child DIV) each contains different content under the product image that expands the height. 5 are randomly selected and placed at the top of the list, thats why i want to cut it off at 5.
    "Problems cannot be solved by the same level of thinking that created them.

  4. #4
    Join Date
    Jul 2006
    Posts
    207
    Seeing as the height of the parent DIV depends on the height of the child DIVs, there's really no way to determine what the height of the parent DIV should be with CSS, you would have to resort to a JavaScript solution that likely calculates the height of the five child DIVs and gives the total height to the parent DIV.

  5. #5
    Join Date
    Jun 2006
    Location
    Boston, MA
    Posts
    383
    im not real strong with javascript just yet.. but ill do some reasearch! thanks a lot. i figured JS would probably be the best path for this issue
    "Problems cannot be solved by the same level of thinking that created them.

Thread Information

Users Browsing this Thread

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

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



Recent Articles