Connecting Tech Pros Worldwide Forums | Help | Site Map

Curious IE "feature"

Newbie
 
Join Date: Nov 2006
Posts: 2
#1: Nov 11 '06
A curious problem I've encountered which can be seen with a simple piece of HTML:

Expand|Select|Wrap|Line Numbers
  1.  <div id="a" style="position: absolute; top:5px; left: 5px; width:100px; height:100px; border: 1px solid red;">
  2.     <div id="b" style="position: absolute; top:0px; left: 0px; width:100px; height:99px; border: 1px solid red;"></div>
  3.     <div id="c" style="position: absolute; top:99px; left: 0px; width:100px; height:1px; border: 1px solid red;"></div>
  4. </div>
  5.  
  6. <br /><br /><br /><br /><br /><br /><br />
  7.  
  8. <script type="text/javascript">
  9.     document.writeln("style height: "+ document.getElementById("c").style.height+"<br />");
  10.     document.writeln("client height: "+document.getElementById("c").clientHeight+"<br />");
  11.     document.writeln("offset height: "+document.getElementById("c").offsetHeight+"<br />");
  12. </script>
This is supposed to generate 3 divs: a 100x100 box containing to more boxes, the first 99x100 in size, the second 1x100 in size. This is not what happens with IE 6.0, though (i haven't tested IE 7.0 yet). In Firefox 2.0 and Opera 9 works as you would expect, viewing in IE 6.0 expands the second inner div to 19px or so..

I have no idea what is going on here... I tried a few extra style attributes (like line-height:0px) but haven't found anything to remedy the situation...

Inspecting the DOM, IE shows the correct style attributes (i.e. height: 1px) but theclientHeight and offsetHeight attributes are both 15px...

You can see images of what is displayed here:
http://blog.bluecaldera.com/2006/11/...s_ie_feat.html

Any help would be greatly appreciated!

Thanks

Newbie
 
Join Date: Nov 2006
Posts: 2
#2: Nov 12 '06

re: Curious IE "feature"


Quote:

Originally Posted by titch

A curious problem I've encountered which can be seen with a simple piece of HTML

OK, problem solved!

Adding a "line-height:0px" property to div C solved the problem. I am certain I tried this before, but I tried it again whilst playing around with some other properties, and it worked this time.. I have no idea why it didn't work the first time!

Adding "overflow: hidden" also does the trick.
Reply


Similar HTML / CSS bytes