Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: "autostretching" divs

  1. #1
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default "autostretching" divs

    IN http://rambo.id.uw.edu.pl/viewer.html I attempted to create "tableless" dwesign, and while it looks seemingly OK, it required some very fuzzy logic and obscure math to get that right: particularily "window border" and "scrolled window" divs have ugly hardcoded dimensions.

    My question is: does anyone know or has heard of "snapping" divs to other elements' "containers" so their sizes are calculated by browser (they simply gonna stretch from A to B, even if position of B can be changed- yes, I want to implement "window resizing"), and are not needed to be hardcoded.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You mean height: 100%; width: 100%; ? I don't quite grasp what you mean by:
    "snapping" divs to other elements' "containers"
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well, in X/Motif terminology it would be something like this:
    XmCreateWidget("appWindow", someWidgetClass,
    "viewerAera",
    XmNbottomAttachment, "statusBar",
    XmNtopAttachment, "toolBar", ...);
    ...more or less,

    There are no "attachments" in CSS (unfortunately), there's only positioning and dimensions, so I'm hoping somebody came with some workaround...

    my point is, that div ("viewerAera") with height 100% inside another div ("appWindow") surrounded by top and bottom divs (the mentioned statusBar and toolBar id's), was going mad and rendered either thru the bottom "statusBar" div or on right side of it. I tried relative positioning, but then it went even worse because floating images in divs would simply overlap across the "bars".

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Aha, I see.

    What you want to do, I think, is to put all three elements -- toolbar, window and status bar -- into one element and set their widths to 100%, then stretch the outer container.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    not just that, the statusBar and toolBar should remain fixed in, in order, top and bottom of "appWindow" div, while "viewerArea" is meant to stretch "snapping" to them, when "appWindow" changes size.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    For that, you just need to give them fixed percentage heights.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ... yeah, and that's the problem that raises obvious question: since IE doesn't support table, table-row, table-cell display properties (and it looks like IE7 still won't) I can't exactly use them, thus images and text inserted into divs, that need to be small in percentage, will overflow the box- theoretically I can use <br style="clear: both" />, but it's gonna create nocicable "gap" at the bottom of divs. I know, because tried...

    Well, seems that the only solution is either not to care about 62% of viewers with IE :-p, or still having table-based layout

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If the divs are set to margin:0; padding:0; display:block; and overflow:hidden; that shouldn't be a problem.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    http://rambo.id.uw.edu.pl/test.html
    A test behaviour page demonstrating what happens and what I want to avoid

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If everything is contained inside, say - a division with dynamic dimensions expressed in pixel units, you can use css style to set the contained elements:

    Code:
    float:left;
    and their height and width to whatever percentage of the container that you wish them to occupy. Then they will stack from left to right across the container as long as their widths do not add up to more than 100% (or perhaps a little less). The one tricky part is that although IE will generally work OK with just that, all other browsers require you to have an empty division at the bottom of the container with its style set to:

    Code:
    clear:left;
    Otherwise, you will have unfilled elements not extending for the height of the container.

    If you want some/one of the content elements to wrap to the next line, either give them clear:left; style or make sure that the preceding row of elements adds up to 100% width.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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