Results 1 to 6 of 6

Thread: CSS question (problem)

  1. #1
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default CSS question (problem)

    Hello EoFF CSS gurus,
    Perhaps you can help me understand what I'm doing incorrectly here.

    Here's a simple HTML page that outlines the problem. Check out the source code specifically.

    I need to know why the <div> tags are behaving this way with this CSS.

    Thanks a bunch for any insight you can provide!
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    The Anti Mosher Balzac's Avatar
    Join Date
    Feb 2008
    Location
    Hangcaster, England
    Posts
    1,534
    Blog Entries
    1

    Default

    The div tags aren't working right because you have the "float" command in them.

    As for your other problem, I have no idea.
    You hold my heart in your manly hands I wanna feel the throb of your handsome gland. I wanna hold you tight like a newborn kitten, against my flesh like a cashmere mitten. Tickly tick, I'm makin' skin bump heaven and all the way down it's lookin' cleanly shaven. Prickety pricks, it's stubble on stubble I better slow down or I'm in real trouble. Want you, touch you, feel you, taste you! Knick knack whacky whack 'till I see the man stew. spin you around let me see that hole! I'm a tunnelin' in a like a short hair mole. Once I'm inside I'm gonna leave a trace, half in there and half on that face! One finger, two finger, there fingers gone! Mano a mano I love you John!

  3. #3
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    Problem #1 is solved. A web-developer friend pointed out that adding this before closing the blue div would solve the problem:
    Code:
    <div style="clear: both;"></div>
    The second problem he said was a padding issue. I'm still a bit unsure on that one.

    EDIT: Problem #2 solved by trial and error. It's not a padding issue. Instead, turning off the borders on the red and green divs fixes the problem.

    I guess that about wraps that up. Thanks for the suggestions.
    I'll leave this open if anyone has anything to add.

  4. #4
    i n v i s i b l e Tech Admin o_O's Avatar
    Join Date
    Jun 2001
    Location
    New Zealand
    Posts
    2,957
    Blog Entries
    1

    FFXIV Character

    Humphrey Squibbles (Sargatanas)

    Default

    Ok, for problem one:
    When the height of the parent div is evaluated, it takes into consideration the height/content of any child element in the <u>normal flow</u> of the page. Since floated elements are removed from the normal flow to allow other content to flow around them, the div disregards their heights, even though they are its children. My solution is either to not float one of the child divs, leaving it in the normal flow and forcing the parent div to stretch to its height, or adding a non-floated block element inside the parent div with the "clear" attribute.

    And for problem two:
    I'm fairly certain this has to do with the way IE and Firefox interpret the "width" attribute of block elements. For clarity's sake I'll just point out that a block element is always rendered with a line break immediately following unless the CSS "display: inline;" is explicitly used.
    Anyway, with block elements, IE considers the width property to include the internal space of the element (i.e. the screen space taken up by the block's content) as well as the external space taken up by margins, padding, spacing and <u>borders</u>. In Firefox, these four attributes are not included in the "width" of the element (and this is the correct way ).
    Upon closer inspection, you'll notice that there's a four-pixel overlap in firefox, and with one-pixel borders.... So my solution in this case is to set the width of one or both child divs to 49%, which produces (almost) no discernable difference between IE and Firefox.

  5. #5
    ..a Russian mountain cat. Yamaneko's Avatar
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    15,927
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default

    Get a room!

  6. #6
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    Quote Originally Posted by o_O View Post
    Ok, for problem one:
    When the height of the parent div is evaluated, it takes into consideration the height/content of any child element in the <u>normal flow</u> of the page. Since floated elements are removed from the normal flow to allow other content to flow around them, the div disregards their heights, even though they are its children. My solution is either to not float one of the child divs, leaving it in the normal flow and forcing the parent div to stretch to its height, or adding a non-floated block element inside the parent div with the "clear" attribute.

    And for problem two:
    I'm fairly certain this has to do with the way IE and Firefox interpret the "width" attribute of block elements. For clarity's sake I'll just point out that a block element is always rendered with a line break immediately following unless the CSS "display: inline;" is explicitly used.
    Anyway, with block elements, IE considers the width property to include the internal space of the element (i.e. the screen space taken up by the block's content) as well as the external space taken up by margins, padding, spacing and <u>borders</u>. In Firefox, these four attributes are not included in the "width" of the element (and this is the correct way ).
    Upon closer inspection, you'll notice that there's a four-pixel overlap in firefox, and with one-pixel borders.... So my solution in this case is to set the width of one or both child divs to 49%, which produces (almost) no discernable difference between IE and Firefox.
    Hats off to you, good sir. You made the solution make sense.

Posting Permissions

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