...

View Full Version : vertical gaps in ie6 and ie7



sudhakararaog
11-18-2009, 10:17 PM
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.

Excavator
11-19-2009, 12:11 AM
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 (http://www.quirksmode.org/css/clearing.html).

You can also get rid of mysterious gaps by using a CSS reset (http://perishablepress.com/press/2007/10/23/a-killer-collection-of-global-css-reset-styles/). I put a variation of the following at the top of my CSS in everything I code -
* {
padding: 0;
margin: 0;
border: 0;
}

Have a look at this code and see if it works for you -
<!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>

sudhakararaog
11-19-2009, 12:30 AM
thanks for letting me know.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum