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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    137
    Thanks
    1
    Thanked 0 Times in 0 Posts

    vertical gaps in ie6 and ie7

    my question is about ie6 and ie7 creating unwanted vertical gap of 3px

    in my page i have an outer div which is holding 4 inner divs following is the code

    #outer{
    float: left;
    width: 900px;
    height: auto;
    }

    #outer .inner1{
    float: left;
    width: 200px;
    height: auto;
    }
    #outer .inner2{
    float: left;
    width: 200px;
    height: auto;
    }
    #outer .inner3{
    float: left;
    width: 200px;
    height: auto;
    }
    #outer .inner4{
    float: left;
    width: 300px;
    height: auto;
    }

    after this a new div starts with width 900px with the remaining page content, in order to clear the floats before the new div starts i have used

    <br class="break" />
    .break{
    clear: both;
    }


    due to this the next div top edge starts exactly below the bottom edge of the outer div which is holding the inner divs, only in ie6 and ie7 there is a small vertical gap which i want to remove, as of now i have used
    *margin: -3px 0 0 0; and _margin: -3px 0 0 0; for ie6 and ie7 for the next div and it looks similar to all other browsers

    instead of using the -3px top margin is a way i can avoid the 3px vertical gap that ie is creating.
    can i change .break to
    .break{
    clear: both;
    height: 1px;
    }

    i am not very sure of this. sometimes this code also works <div class="clear"></div> .clear{clear: both;} as an alternative to <br class="break" />

    also i have tried using the following code to fix ie6 and 7

    * html .divname{
    margin: -3px 0 0 0;
    }
    *+html .divname{
    margin: -3px 0 0 0;
    }


    the advantage of using * html does not give any warnings when i validate the code from w3.org website however using _ and * gives a warning message for using _ and *

    please advice if there is a way to avoid the 3px gap in ie6 and 7 without the above code or if there is no other alternative other than to use any of the 2 techniques

    thanks.

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello sudhakararaog,
    A couple things - when you float #outer, there is no need to clear the floats contained by #outer.
    If you remove float:left; from #outer, it might work better for you to clear the floats by using overflow: auto;
    Here's a site that shows how that works.

    You can also get rid of mysterious gaps by using a CSS reset. I put a variation of the following at the top of my CSS in everything I code -
    Code:
    * {
    	padding: 0;
    	margin: 0;
    	border: 0;
    	}
    Have a look at this code and see if it works for you -
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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">
    html, body {
    	font: 100.1% "Comic Sans MS";
    	background: #FC6;
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: 0;
    	outline: 0;
    }
    #outer{
    	width: 900px;
    	margin: 30px auto 0;
    	overflow: auto;
    	background: #ccc;
    }
    	.inner1, .inner2,
    	.inner3, .inner4 {
    		height: 200px;
    		width: 200px;
    		float: left;
    	}
    	#outer .inner1{background: #fff;}
    	#outer .inner2{background: #9c3;}
    	#outer .inner3{background: #660;}
    	#outer .inner4{background: #03f;}
    #content {
    	width: 900px;
    	margin: 0 auto;
    	background: #f00;
    }
    </style>
    </head>
    <body>
        <div id="outer">
            <div class="inner1">Inner One</div>
            <div class="inner2">Inner Two</div>
            <div class="inner3">Inner Three</div>
            <div class="inner4">Inner Four</div>
        <!--end outer--></div>
                <div id="content">
                    <p>
                        Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna 
                        aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no 
                        sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam 
                        nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo 
                        duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
                    </p>
                <!--end content--></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Posts
    137
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks for letting me know.


  •  

    Posting Permissions

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