|abs:pos element positioning to parents padding|
in IE, of course
I have a setup of nested lists, that ive styled to to appear as a set of tabs, with a the nested list appearing as a submenu underneath.
The parent list has position:relative; so i can use position:absolute; on the nested list to put it correctly underneath.
Im wanting the sub list to be positioned exactly one pixel from the left of the parent list container, but in IE its positioning it exactly one pixel to the left of the padding on the list. Op + FF are behaving as expected.
HTML4 strict full DTD
You could try using a conditional comment to include a stylesheet hack for IE. In other words, define your style as you have (for Firefox, Op, etc.), and then wrap your IE style in conditional comments.
As for the fix, adjust the top/left (or whatever you're using to specify the location of the absolutely positioned element) to compensate for the padding of the containing element. For example, if your containing element has a padding of 10px, then adjust the top/left to be -10px.
I haven't verified that will work, but I think it should. You may also need to adjust the z-index to make sure your absolutely positioned element is on top.
I had considered C comments and the negative position fix, but was wondering if anyone knew of the reason for this strange problem, as its one i havent come across before.
If possible id like to stay as hack/workaround free as possible, but thats looking increasingly unlikely :(
So I'm assuming this may look something like this:
<li><a href="#">Tab 1</a>
<li>Sub item 1</li>
<li>Sub item 2</li>
If you apply padding to the top level Tab 1, then I think it makes sense that everything contained within that list is going to be within that padding.
Therefore, maybe you should remove the padding from the <li> and instead apply it to <a>? Or you could wrap "Tab 1" in a span and apply it to that. Just an idea.
|Im wanting the sub list to be positioned exactly one pixel from the left of the parent list container, but in IE its positioning it exactly one pixel to the left of the padding on the list. Op + FF are behaving as expected. |
This may have something to do with how different browsers handle clearing marker-box space for lists. Moz uses padding, IE uses margin. So depending on how you've handled those two properties on the list elements, this could be the source of the discrepancy.
For instance, if you've set a padding but not a margin (and the margin hasn't been zeroed out), then IE is going to add it's default list margin (the marker box) into the mix while FF won't (the explicit padding will override FF's default padding used for marker-box space).
If you haven't already, I would check that you've negated all default margin and padding on the lists, then explicitly set one or the other and see how it looks.
Are you sure you're not in quirks mode? Are you using a doctype?
er yeah im pretty sure im not in quirks. Hence
in my original post.
Fotiman - thats exactly like the code. The padding is on the a: not the li
CEM - the margin and padding are zeroed on everything at the start of the CSS :(