Making DIV stretch to fit overflow

Discussion in 'HTML & Website Design' started by Negative Zero, Dec 2, 2008.

  1. #1
    I'm really in need of finding a way to make a DIV stretch out so that things don't overflow in the first place. In IE6, the CSS overflow property behaves incorrectly. You can see an example http://www.quirksmode.org/css/overflow.html

    What I'm trying to do is emulate this behavior in FireFox and IE7. I'm not concerned with breaking the W3 rules, what I'm concerned with is that it works. Is it possible at all?
     
    Negative Zero, Dec 2, 2008 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Correct behavior dictates that a dimensioned element does not] stretch to contain its content. IE6 gets it wrong. IE will not allow overflow of a dimensioned box. There is no fix.

    If I've misread your question, please rephrase it for more clarity of purpose.

    cheers,

    gary
     
    kk5st, Dec 2, 2008 IP
  3. i.run.shit

    i.run.shit Peon

    Messages:
    61
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You could always try adding "min-height: value;" to your CSS template opposed to just the "height: value;." There's always a fix for everything, there's always a way to get look that you want, even if you have to go about it a different way.
     
    i.run.shit, Dec 2, 2008 IP
  4. designz

    designz Peon

    Messages:
    301
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    IE doesnt recognise min-height or min-width .
     
    designz, Dec 2, 2008 IP
  5. i.run.shit

    i.run.shit Peon

    Messages:
    61
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    IE8 does support min-height. I've tested my own website with it. But that's only IE8, I guess they're fighting as hard as they can to keep up with the competition.
     
    i.run.shit, Dec 2, 2008 IP
  6. Negative Zero

    Negative Zero Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks, but I'm quite aware that the behavior is incorrect. What I was hoping for was a method for emulating that incorrect behavior. A trick or something, perhaps, if I'm lucky, a correct method for accomplishing such behavior.
     
    Negative Zero, Dec 2, 2008 IP
  7. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #7
    Ah, OK. Given that you want a box, <div id="stretchybox"> e.g., to have a height, but will grow with additional content;
    
    #stretchybox {
      min-height: 100px;
      }
    
    * html #stretchybox {
      height: 100px;
      }
    Code (markup):
    That will do for modern browsers and IE7. For IE6,which doesn't support min-anything, we use the "star html hack". Only IE6 thinks there is an element for html to descend from, so only IE6 sees "* html".

    cheers,

    gary
     
    kk5st, Dec 2, 2008 IP
  8. WebCatch

    WebCatch Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Try putting the div in a container div, then float all divs left. I heard somewhere that that worked but haven't yet had a chance to try it out so apologies if it doesn't!
     
    WebCatch, Dec 3, 2008 IP
  9. reice0116

    reice0116 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I know this is an old thread - however it was something I needed to figure out and I found this through a google search, so I hope this helps others:

    DIVs with min- stylings will stretch to content, however, when accessing the DOM values of the div will return null values for width and height. In other words, you can't see the dynamic width and height of the div.

    In order to detect the Divs height and width, wrap a table around it. the table will stretch with the div and its offsetWidth and offsetHeight will be accessible through javascript.

    why is this useful? well one example is you can resize outer divs, particularly ones that are absolute and float above the application, to surround its content instead of being a tiny square in the upper left corner of the dynamic content.
     
    reice0116, Nov 10, 2011 IP