Forum Moderators: not2easy

Message Too Old, No Replies

Example of hasLayout related bug still present in IE

         

DrDoc

2:04 am on Mar 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Trigger scenario:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>
<head>
<title>Test Page</title>
<style type="text/css">
#foo {
margin-left: 175px;
}
</style>
</head>
<body>
<div id="foo">
<form>
<fieldset>
<legend>Contact Information</legend>
Name<br>
<input type="text" name="name" value=""><br>
Email Address<br>
<input type="text" name="email" value=""><br>
Phone Number<br>
(<input type="text" name="phone1" value="" size="3">) <input
type="text" name="phone2" value="" size="3">&ndash;<input
type="text" name="phone3" value="" size="4">, ext. <input
type="text" name="phone4" value="" size="4">
</fieldset>
</form>
</div>
</body>
</html>

Naturally, you would expect the code to render something like:

Name 
[_______________]
Email Address
[_______________]
Phone Number
([____]) [____]-[______]

Alas, it doesn't ... IE renders it thus:

Name 
[_______________]
Email Address
[_______________]
Phone Number
([____]) [____]-[______]

Of course, the space in front of the two inputs is exactly equal to the

margin-left
applied to the
#foo
div element.

Silly enough, the anonymous text elements are unaffected.

Changing the

#foo
declaration slightly fixes the problem:

#foo {
margin-left: 175px;
zoom: 1;
}

[edited by: DrDoc at 2:06 am (utc) on Mar. 22, 2008]

omegaman66

2:32 am on Mar 22, 2008 (gmt 0)

10+ Year Member



Confused. Removing the margin 175 line puts all elements like you want them if I understand correctly. But all the way left. I tried applying the 175 to the body of the document but the foo div ignores the margin.

It looks like the 175 margin is being applied to the division in your code and then again to the boxes again withing the division but not applied to the text?

Doesn't seem to be following the rules properly to me?

DrDoc

3:37 am on Mar 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like the 175 margin is being applied to the division in your code and then again to the boxes again withing the division but not applied to the text?

Doesn't seem to be following the rules properly to me?

Exactly ... It's one of those IE bugs.

SuzyUK

6:21 pm on Mar 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks Doc, came across this one recently again too, the not so well known "Inherited Margins on Form Elements" bug

meant I had to give in [webmasterworld.com] and put the hasLayout trigger in my favourite templates for the "just in case" scenarios.

it gets worse too if more ancestor elements have margins then the form elements will inherit the sum of them all and all the ancestors with margins need the fix :o

also note the your last row of inputs are not affected.. due to the "(" before the first one ..