Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Div Border creates Padding Problem in Firefox

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

    Default Div Border creates Padding Problem in Firefox

    I have 2 <div>'s one inside the other. When I put a border around the outer <div> I get unwanted padding in Firefox between the outer <div> and inner <div>. It works fine in IE.

    In order to explain this better an example is at the URL below:
    http://www.fuse11.com/examples/test.html

    The red border of the outer <div> should touch both the blue background of the outer <div> and the green background of the inner <div>.

    I have no padding or margins that should create spacing between the border of the outer <div> and the top of the inner <div>. If the border is taken off the extra padding goes away. The source code of the example is very similar to the code of my original file.

    I'm at a loss on what the problem is... Thanks,

    Anthony

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Whoa.... I have no idea. (This probably confuses me more than you)
    - Mike

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

    Default

    I got the solution for anyone who is interested.

    It's the padding on your hx and p tags which is creating the space. The reason you're seeing it with the border is because of collapsing margins. Without border or padding, adjacent margins will collapse
    Thanks

  4. #4
    Join Date
    Jul 2006
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    *{margin:0px; padding:0px}

    try this ... I use it as the gobal reset for padding and margins.

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    He already has that done
    - Mike

  6. #6
    Join Date
    Jul 2006
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    #content {
    PADDING-RIGHT: 20px; PADDING-LEFT: 20px; MARGIN: 0px 150px; WIDTH: 300px; BACKGROUND-COLOR: #009966
    }
    </STYLE>

    <META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
    <BODY>
    <DIV id=contentContainer>
    <DIV id=content>
    <H1>“Title” </H1>
    <H2>Sub-Title</H2>
    <P>Lots of text</P>
    <P>and more and more </P></DIV></DIV></BODY></HTML>



    Mike, I don't see the

    *{margin:0; padding:0}

    Something about the * (global reset) that does the trick when using different engine browsers.

    He does have margin:0 but that doesn't solve the issue.

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Oops.. Stupid mistake, I missed the asterix. Sorry about that one.
    - Mike

  8. #8
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Also..

    Mike, I don't see the

    *{margin:0; padding:0}
    When using a number like that, you have to say what it is. Whether it's px , em, percentages, elephants, etc. Sometimes browsers don't read "margin:0" right.


    ^^ My 200th Post ^^
    - Mike

  9. #9
    Join Date
    Jul 2006
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Mike you are correct ... forgot about that ...

    It's the * that I was trying to convey.

  10. #10
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt
    *{margin:0; padding:0}
    When using a number like that, you have to say what it is. Whether it's px , em, percentages, elephants, etc.
    No, you don't. Non-zero length values require units, but zero (0) pixels is exactly the same as zero percent: zero.

    Sometimes browsers don't read "margin:0" right.
    Not that I've ever seen, and if so, those browsers are broken. A browser has every right (in fact, a duty) to ignore "margin: 10", but not a value of zero.

    Mike

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
  •