I have an <a>
element, after which I want to show a >
sign, using the :after
pseudo element.
The <a>
element's content is dynamic, so its width changes, and sometimes the content event spans a few rows (since this <a>
element is inside a <div>
who's width is fixed).
I would like the >
's horizontal position to start at the end of the longest row. That is, when I give it that right:0;
rule, it should be at the right most edge of the element (the vertical position doesn't matter right now):
That's the way it behaves in FF, but in Chrome and IE, the >
appears at the end of the shortest row:
I'd like to understand what causes the difference between the browsers, but more importantly, I'd like all browsers to behave like FF - placing the :after
at the end of the longest row. Is that possible?
I put the above code on dabblet
a
element, being a relatively positioned inline element, is the containing block for its:after
pseudo-element, which is absolutely positioned. The problem is that the text in youra
is multiline, and the spec says it does not define the shape or dimensions of a containing block in such a scenario. This is why you're seeing differences in browser behavior - in other words, browsers don't know what to do in such a scenario so they do whatever they think is best. – Cyndie