When absolutely positioning a pseudo-element inside of an inline element that starts a new line, the pseudo-element is incorrectly positioned at the end of the previous line. This happens inside a flow of inline text, where the inline element (such as an anchor or span) resides. This seems to be an undesired behavior because all other modern browsers (latest Chrome, Opera, IE10 PP2) position the pseudo-element differently from Firefox 11. Here is a JSBin that demonstrates this: http://jsbin.com/ucokah/edit#html,live Hover over the link to see the pseudo-element.
Created attachment 613214 [details] reporter's testcase (JSBin really doesn't count as a simplified testcase)
The line-break is happening inside the <a>, not before it (in terms of our resulting box tree). You can see this pretty clearly if you put a 1px left border on the <a>. So the containing block for the abspos element ends up being the empty inline box before the line-break (see bug 489100). That seems to be all that's going on here; in particular, this is not related to pseudo-elements in any way; a normal child element would do the same thing. I don't know offhand whether other browsers put the linebreak in a different place or whether they don't suffer from bug 489100.
Latest stable Chrome and Safari put the left border on the new line, and the child element is positioned as desired. IE10 PP2 is the same. Latest stable Opera, however, will work as originally expected with no border, but when you add the border, it behaves the same way as Firefox. In my opinion, it seems nonsensical for the content to be on a new line while the left border is on the previous line. This doesn't happen if I throw a "br" tag in before the parent element, so why should it happen if the line break is automatically inserted? But hey, what do I know? :)
The linebreak behavior is a bit silly, imo, yes. The issue is that we start the parent element, then discover the kid won't fit and break before the non-fitting kid... but part of the parent did fit, so stays on the previous line. I agree that checking for empty boxes there and not creating them would be nice; that's what Opera seems to be doing based on your description.
(Related to, but not duplicate of, bug 389587.)
Well, fixing that would fix this bug too, yes.
5 years ago