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 I
There is a work-around that allows font-sizes to be relative (em
or %
): add another class with the pseudo-element font-size
reducing the size.
I've put together a fiddle showing the workaround but the basic code is below:
<p class="one">Test (1.25em = 20px)</p>
<p class="one two">Test (2em = 32px but 2.5em = 40px in IE)</p>
<p class="one one-ie two">Test (2em = 32px)</p>
The styles then look like this:
body {
font-size: 16px;
}
.one::before {
content: "::before";
font-family: monospace;
font-size: 1.25em;
margin-right: 10px;
}
.one-ie::before {
font-size: 0.8em;
}
.two::before {
font-size: 2em;
}
Most browsers will override the .one-ie::before
selector with .two::before
and IE's compounding will essentially negate the previous font-size
. If IE fix the bug and allow pseudo-element styles to override rather than compound, the hack gets overridden like every other browser.
I see the test page "sit amet" as huge in Firefox 4.0.1. Are you sure this is IE only and not actual spec'd behavior?
edit: and safari too. I'm on a Mac. I don't think this is an IE bug.
This might have something to do with the difference between the parsed DOM trees from IE8 to IE9.
Internet Explorer 8:
<html>
<head>
<body>
<div class="outer">
<p class="inner">
Internet Explorer 9:
<html>
<head>
<body>
<div class="outer">
<p class="inner">
I've seen similar in other versions of IE using ems too. Try setting
HTML {
font-size: 100%;
}
Should fix 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.