I have found a bug in IE9 but googling for it hasn't helped finding any solution yet.
The following works fine in FF 3 + 4, Chrome, Opera and even IE8, but not in IE9.
The HTML:
<div class="outer">
<p class="inner">Lorem ipsum dolor</p>
</div>
The CSS:
div p {
font-size: 1.2em;
}
div p:after {
content: " sit amet";
}
div p:after {
font-size: 1.3em;
}
div.outer p:after,
div p.inner:after {
font-size: 3em;
}
The "sit amet" is huge in IE9, as it seems to multiply the font-size again and again. It's not possible to overwrite it with "!important" or other means of increasing the specificity (as e.g. the "div.outer" should already do it). It even seems that it gets multiplied within the same declaration, i.e. div.outer p:after, div p.inner:after
won't multiply by 3, but by 9!
(Please note that the "inner" and "outer" classes are not necessary here. The same happens by declaring div p {}
again and again. But it makes only sense with classes as a real-world example.)
Here is a test page: http://dl.dropbox.com/u/4667354/temp/ie9-bug.html
Is there any solution?
Edit:
To clarify two misunderstandings:
em
are used. The bug is that font-sizes in generated content cannot be overwritten and will multiply anyway when trying to. I.e. setting the font-size in div p:after
once works, but setting it again multiplies instead of overwrites it.You could try using rem
instead of em
, IE9 supports it, then your sizes will then be relative to the base font size instead of multiplying together. Here's a good explanation.
I would guess the difference here is that IE9 is treating the generated content as a child element while the other browsers aren't, hence the multiplication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With