HTML Tutorial


 /help/HTML Help Forum   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
vertical gaps in ie6 and ie7
Post new topic   Reply to topic    HTML Help Forum -> CSS
View previous topic :: View next topic  
Author Message
sudhakararaog



Joined: 01 Oct 2009
Posts: 100

PostPosted: Wed Nov 18, 2009 1:20 pm     vertical gaps in ie6 and ie7 Reply with quote

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.
sticks464



Joined: 31 Dec 2006
Posts: 2625

PostPosted: Wed Nov 18, 2009 2:23 pm     Reply with quote

See if some of this helps
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">
* {
   margin:0;
   padding:0;
}
body {
   background:#FF9;
   font:62.5%/1.5 "Palatino Linotype", "Book Antiqua", Palatino, serif;
}
#container {
   width: 900px;
   border:1px solid #DDD;
   font-size:1.2em;
   margin:10px auto;
}
#outer{
   overflow:hidden;
   background:#0C6;
   zoom:1;
}
#outer div {
   float: left;
   width: 200px;
   height:1%;
}
#outer div p {
   padding:5px;
   text-align:justify;
}
#content {
   width:900px;
   background:#F00;
}
#content p {
   padding:5px;
   text-align:justify;
}

</style>
</head>

<body>
<div id="container">
<div id="outer">
<div class="inner1">
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque. Nunc venenatis enim nec quam. Cras faucibus, justo vel accumsan aliquam, tellus dui fringilla quam, in condimentum augue lorem non tellus.</p>
</div>
<div class="inner2">
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque. Nunc venenatis enim nec quam. Cras faucibus, justo vel accumsan aliquam, tellus dui fringilla quam, in condimentum augue lorem non tellus.</p>

</div>
<div class="inner3">
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque. Nunc venenatis enim nec quam. Cras faucibus, justo vel accumsan aliquam, tellus dui fringilla quam, in condimentum augue lorem non tellus.</p>
</div>
<div class="inner4">
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque. Nunc venenatis enim nec quam. Cras faucibus, justo vel accumsan aliquam, tellus dui fringilla quam, in condimentum augue lorem non tellus. Pellentesque id arcu non sem placerat iaculis. Curabitur posuere, pede vitae lacinia accumsan, enim nibh elementum orci, ut volutpat eros sapien nec sapien. Suspendisse neque arcu, ultrices commodo, pellentesque sit amet, ultricies ut, ipsum. Mauris et eros eget erat dapibus mollis. Mauris laoreet posuere odio. Nam ipsum ligula, ullamcorper eu, fringilla at, lacinia ut, augue. Nullam nunc.</p>
</div>
</div><!-- end #outer -->

<div id="content">
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque. Nunc venenatis enim nec quam. Cras faucibus, justo vel accumsan aliquam, tellus dui fringilla quam, in condimentum augue lorem non tellus. Pellentesque id arcu non sem placerat iaculis. Curabitur posuere, pede vitae lacinia accumsan, enim nibh elementum orci, ut volutpat eros sapien nec sapien. Suspendisse neque arcu, ultrices commodo, pellentesque sit amet, ultricies ut, ipsum. Mauris et eros eget erat dapibus mollis. Mauris laoreet posuere odio. Nam ipsum ligula, ullamcorper eu, fringilla at, lacinia ut, augue. Nullam nunc.</p>
</div><!-- end #content -->

</div><!-- end #container -->
</body>
</html>


Last edited by sticks464 on Wed Nov 18, 2009 2:47 pm; edited 1 time in total
sudhakararaog



Joined: 01 Oct 2009
Posts: 100

PostPosted: Wed Nov 18, 2009 2:38 pm     Reply with quote

thanks for replying

the code you sent works fine in all browsers including ie6 and 7 with no vertical gaps and there are no vertical gaps for the content div

normally when there are divs that float and if a new div starts like the content div if clear is not used the content in the content div would appear in some random location however that was not the case in your code it started exactly below the previous floating divs, does this depend on certain conditions.
sticks464



Joined: 31 Dec 2006
Posts: 2625

PostPosted: Wed Nov 18, 2009 3:01 pm     Reply with quote

IE requires what is known as 'hasLayout' which requires a width and height to be set to containers holding floats.

Quote:
Sitepoint
Quote:
The simplest way for an element to gain a layout is for it to have a dimensional CSS property applied—for example, a width or height. However, in situations where you don’t wish to apply a specific width or height to the element, there are several other CSS properties that, when you apply them to the element, will cause that element to gain a layout.

Those other properties are:

* display: inline-block
* height: (any value except auto)
* float: (left or right)
* position: absolute
* width: (any value except auto)
* writing-mode: tb-rl
* zoom: (any value except normal)4

Internet Explorer 7 has some additional properties that cause an element to gain a layout (this is not an exhaustive list):

* min-height: (any value)
* max-height: (any value except none)
* min-width: (any value)
* max-width: (any value except none)
* overflow: (any value except visible)
* overflow-x: (any value except visible)
* overflow-y: (any value except visible)5
* position: fixed


If you look at my edited post above, I added two more that will even make IE5 work.
sudhakararaog



Joined: 01 Oct 2009
Posts: 100

PostPosted: Wed Nov 18, 2009 3:16 pm     Reply with quote

thanks for the information.
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum -> CSS All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial