Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    108
    Thanks
    22
    Thanked 2 Times in 2 Posts

    'p' in div behaves strangely in IE8?

    the red part below, 'p' tag, seems to have a bottom margin stick out of the containing 'div', pushing down the following footer -- copyright part. If 'p' tag is erased, it will show the position of footer correctly. This is what happens in IE8. However, IE7 and FF4 does behave as expected.

    if the 'p' comes at the bottom of the 'div', I know that there is collapsing margin issue, resulting a bottom margin stuck out. But 'p' just lies at the start of the div which also has a min-height, 'p' should stretch its margin out of the div. is this a bug in IE8?

    any help is appreciated

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
    	margin: 0;
    	padding: 0;
    	background-color: #FC0;
    }
    #wrapper {
    	padding: 0;
    	width: 900px;
    	margin: 0 auto;
    	background-color: #FFF;
    	min-height: 300px;
    }
    #footer {
    	color: #FFFFFF;
    	text-align: center;
    	padding: 10px 0;
    }
    </style>
    </head>
    
    <body>
    	<div id="wrapper">
    		<img src="" width="900" height="200" />
            <div id="center">
                <p>aaa</p>
            </div>
    	</div>
        <div id="footer">Copyright © 2005-2011 HHHHHHHHHHH</div>   
    </body>
    </html>
    also the red part can be replaced with <div style="margin-bottom:10px">aaa</div>. You will know what I mean by saying the margin bottom of 'p'

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,758
    Thanks
    41
    Thanked 191 Times in 190 Posts
    insert *{margin:0px; padding:0px;} as first line in CSS. Clears problem

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Posts
    108
    Thanks
    22
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by alykins View Post
    insert *{margin:0px; padding:0px;} as first line in CSS. Clears problem
    ah i didn't mean to clear the margin bottom of 'p'
    i just want to reserve that bottom margin.

    To make it clear, replace 'p' with this part <div style="margin-bottom:10px">aaa</div>

    so how to solve the problem? Is it the bug in IE8?
    Last edited by mehere8; 07-23-2011 at 03:33 PM.

  • #4
    Regular Coder
    Join Date
    Dec 2009
    Posts
    108
    Thanks
    22
    Thanked 2 Times in 2 Posts
    Anyone can help?

  • #5
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    all tags have default margins and paddings. alykins is right

    * { margin: 0; padding: 0; }

    try explaining the problem you are having better. I honestly cannot understand what it is your saying. The code you provided really didn't help either.

    All I can say is that if you don't reset the default margins and paddings you will have a margin to the bottom by default of the <p> tag.



    if you look to the right of your screen, you will see some margin-start type of stuff. These are default margins and paddings that I would recommend resetting

  • #6
    Regular Coder
    Join Date
    Dec 2009
    Posts
    108
    Thanks
    22
    Thanked 2 Times in 2 Posts
    ok let's just remove those margins.

    then
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
    	margin: 0;
    	padding: 0;
    	background-color: #FC0;
    }
    #wrapper {
    	padding: 0;
    	width: 900px;
    	margin: 0 auto;
    	background-color: #FFF;
    	min-height: 300px;
    }
    #footer {
    	color: #FFFFFF;
    	text-align: center;
    	padding: 10px 0;
    }
    </style>
    </head>
    
    <body>
        <div id="wrapper">
            <img src="" width="900" height="200" />
            <div id="center">
                <div style="margin-bottom:10px">aaa</div>
            </div>
        </div>
        <div id="footer">Copyright © 2005-2011 HHHHHHHHHHH</div>   
    </body>
    </html>
    if you remove the style from the red part, you will see the footer shift upwards in IE8.
    But you can see the div in red is too short to expand the outer div(center), let alone div(wrapper).
    Do the same in IE7, FF. You will see no change after the style is removed.

    Is it clear? So is it a bug in IE8?


  •  

    Posting Permissions

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