5 replies [Last post]
enave
Offline
Enthusiast
Last seen: 12 years 35 weeks ago
Joined: 2004-10-29
Posts: 86
Points: 0

Hi. I'm trying to figure out why the span in the attached code is in a different spot in IE. It's farther to the right in IE6 and 7. I positioned it absolute, with 400px left margin. I believe that 400px should count from the left of the p tag. But because the label is floated left, IE counts 400px from that.

What should I do to make both browsers do the same thing? thanks in advance.


Prototype

label {
width:200px;
display:block;
text-align:right;

float:left;
clear:left;
}
span {
display:block;
width:200px;
position:absolute;
margin-left:400px;
border:1px solid #ccc;
}


This text is in a different spot in IE and FF
Input Label:

DanA
DanA's picture
Offline
Elder
Last seen: 10 years 24 weeks ago
Timezone: GMT+2
Joined: 2004-08-14
Posts: 1087
Points: 2

Try left:0; in span

Try left:0; in span

enave
Offline
Enthusiast
Last seen: 12 years 35 weeks ago
Joined: 2004-10-29
Posts: 86
Points: 0

Awesome! Thanks!

Awesome! Thanks!

enave
Offline
Enthusiast
Last seen: 12 years 35 weeks ago
Joined: 2004-10-29
Posts: 86
Points: 0

Actually, I'm still having a

Actually, I'm still having a problem. I'll post a new thread if needed since this one has been marked solved. But the problem now is that I intended to put the whole page inside a div with margin:auto so that the page would be centered.

If I use left:0 now, these boxes are anchored to the left side of the window, not to the content div.

So, any other ideas how to solve this? Is this an example of an IE-specific bug? It does this in IE6 and IE7, but every other browser I've tried (opera, ff, safari) work fine.

Tyssen
Tyssen's picture
Offline
Moderator
Brisbane
Last seen: 6 years 1 week ago
Brisbane
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8201
Points: 1386

Make the form position:

Make the form position: relative to establish a new positioning context.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference

enave
Offline
Enthusiast
Last seen: 12 years 35 weeks ago
Joined: 2004-10-29
Posts: 86
Points: 0

Tyssen wrote:Make the form

Tyssen wrote:
Make the form position: relative to establish a new positioning context.

perfect! thanks again!