none
Basic limitation of CSS <div> that tables don't have. RRS feed

All replies

  • Try setting height and width to auto which will do it.
    However, what happens to it and other content on the page if a user increases font size?
    Expression Web MVP
    Saturday, May 29, 2010 6:15 PM
  • Try setting height and width to auto which will do it.
    However, what happens to it and other content on the page if a user increases font size?
    Expression Web MVP


    Steve, height & width auto changes nothing.

    http://php-insite.com/float-clearing-test-auto.html

    Saturday, May 29, 2010 6:20 PM
  • Just curious, but why would you want a div to exhibit such behavior? FWIW, I don't see this as a "limitation" of divs, but a characteristic of block elements in general.

    cheers,
    scott

     


    C'mon, folks. This isn't rocket science, nor neurosurgery. It's "Expression" (singular) "Web" (singular), in that order, followed by a version numeral if you wish to be specific. It is often abbreviated "EW." It is not "Web Expression," "Expressions Web," "Web Expressions," or plain "Expression" or "Expressions." Not using the correct name indicates either ignorance or laziness. Most folks would rather avoid the appearance of either.
    Saturday, May 29, 2010 6:22 PM
  • I tested it in EW 2  and IE8 before I replied.
    If they are both set to auto, the div will shrink to fit the content in it, and in design view will expand sideways when typing and down with new lines.

     

     


    Expression Web MVP
    Saturday, May 29, 2010 6:35 PM
  • The problem can be solved using {display:inline-block} for the containing div element. I just figured this out. Elsewhere on the web, it has been stated that there is no solution to the problem, but I guess that is wrong.

    http://www.php-insite.com/float-clearing-test-inlineblock.html

    This works with IE8 but not IE7.

    Saturday, May 29, 2010 6:43 PM
  • I tested it in EW 2  and IE8 before I replied.
    If they are both set to auto, the div will shrink to fit the content in it, and in design view will expand sideways when typing and down with new lines.

    No, not on my IE 8. When set to auto even in IE8 the div does not colapse to the size of the contents. Only if {display:inline-block} is set will it shrink to the contents.

    http://php-insite.com/float-clearing-test-auto.html

    Saturday, May 29, 2010 6:53 PM
  • The "problem?" OK, granted, maybe I'm a little thick today, but what exactly is the problem? I'm trying to think of circumstances where I would want a div to do this, but so far any applications escape me. Maybe my imagination is on vacation today, so please be so kind as to provide a scenario where this behavior would be useful. No kidding, I really do want to know. You never know; perhaps I'll have an application for this at some time in the future.
    cheers,
    scott


    C'mon, folks. This isn't rocket science, nor neurosurgery. It's "Expression" (singular) "Web" (singular), in that order, followed by a version numeral if you wish to be specific. It is often abbreviated "EW." It is not "Web Expression," "Expressions Web," "Web Expressions," or plain "Expression" or "Expressions." Not using the correct name indicates either ignorance or laziness. Most folks would rather avoid the appearance of either.
    Saturday, May 29, 2010 6:58 PM
  • The "problem?" OK, granted, maybe I'm a little thick today, but what exactly is the problem? I'm trying to think of circumstances where I would want a div to do this, but so far any applications escape me. Maybe my imagination is on vacation today, so please be so kind as to provide a scenario where this behavior would be useful. No kidding, I really do want to know. You never know; perhaps I'll have an application for this at some time in the future.
    cheers,
    scott

    Scott, I wrote a long bit about what I do that would be facilitated by getting the div to fit it's contents and then I hit "Submit" and the post disappeared. Anyway, if you do a Google search on "html <div> shrink fit to contents" you will find 39,000 answers to your question.
    Saturday, May 29, 2010 7:27 PM
  • Heh, heh... well, we apparently define "answer" a little differently. ;-)

    I got about 40K responses, true, but as is usually the case with Google results, beyond the first page or two much was dreck, and even the nine results I read of the first page results did not provide an answer to why such a construct might be used. A number of the posters did not describe their application in practical, specific terms at all, and only one of those that I read provided enough to visualize what he was after.

    And, well, again it is perhaps my own lack of imagination, but I really didn't see much practical application in any of the posts I read. Maybe I just don't conceive layouts that would benefit. Whatever. No biggie, it was just a curiosity thing anyway.

    cheers,
    scott

     


    C'mon, folks. This isn't rocket science, nor neurosurgery. It's "Expression" (singular) "Web" (singular), in that order, followed by a version numeral if you wish to be specific. It is often abbreviated "EW." It is not "Web Expression," "Expressions Web," "Web Expressions," or plain "Expression" or "Expressions." Not using the correct name indicates either ignorance or laziness. Most folks would rather avoid the appearance of either.
    Saturday, May 29, 2010 10:30 PM
  • Sorry about that Google search reply. As far as the use of a collapsing div tag, I think it would very helpful on containers showing borders or background colors like for menus lines and input forms rather than have to give them an explicit width which always wrong on some browser. The example I used which had three boxes enclosed by a div shows up on my pages. It's my style I guess.

    Twinky stuff like this: http://oiyc.org/ I had to fight every pixel to get that page to behave but I think if I could have had certain of the div's collapse on the contents it would have been easier. However, I'll never do a page like that again so don't lecture me about it please.

     

    Saturday, May 29, 2010 11:25 PM