Forum Moderators: not2easy

Message Too Old, No Replies

IE miscalculating "right:170"

absolute positioning

         

Tonearm

12:03 am on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Firefox and Netscape are properly positioning my absolute div 170 pixels from the right, but IE is short exactly 20 pixels. It is positioned correctly in IE with right:150, but then it's wrong in Firefox and Netscape. Is this a known IE bug of some sort?

createErrorMsg

4:14 am on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the absolute positioning relative to the viewport or a container? (i.e., is it nested inside of a relatively positioned box?)

If the element is abs.pos relative to a rel.pos box, the 20px could be coming from a default IE margin or padding on the relatively positioned parent element.

Try zeroing out the margins and padding on the parent. Otherwise, how about posting some code for us to see?

cEM

jetboy_70

10:11 am on Nov 24, 2004 (gmt 0)

10+ Year Member



Is this a typo in your post or your CSS?

right:150

should be

right: 150px;

kaled

11:23 am on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like this could be an issue with the scrollbar. To solve a similar problem, I had to remove the the url from the doctype (html 4.01 trans) to force IE into quirks mode ... crazy!

Kaled.

Tonearm

3:31 pm on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



createErrorMsg -
The absolute positioning is for a div that is right up against the opening body tag. I do have this in my CSS:

* {padding:0;margin:0}
.* {padding:0;margin:0}

Here's the div's CSS:

div.main {position:absolute;margin-top:2em;top:200;left:170;right:170}

jetboy_70 -
Is that space after the colon and explicit "px" necessary? I never use either of those.

kaled -
That sounds very likely to me. I don't use a doctype at all. How can I get it into quirks mode?

kaled

11:40 pm on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For doctype info

[htmlhelp.com...]
[msdn.microsoft.com...]

The doctype must be placed at the top of the page BEFORE the first tag.

Kaled.

Tonearm

1:18 am on Nov 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So you think I will need to use a doctype to set quirks mode to get rid of the gap?

encyclo

1:33 am on Nov 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you don't use a doctype, you are already using quirks mode. For your question regarding whether the "px" is important, the answer is yes, it is vital if you want any hope of getting this working reliably cross-browser.

Your best bet is to run your page through the HTML validator [validator.w3.org] and CSS validator [jigsaw.w3.org] first: in that way, you are removing a large number of the possible problems you might encounter. If your markup is not valid, you are dependent on the individual browsers' error-handling - and that error-handling can vary widely between different browsers because there is no standard way of dealing with invalid markup.

As mentioned by others, your problem is probably related to the fact that there is a permanent scrollbar in IE, but not in Firefox.