IE 11 sub-pixel rendering overflow

2019-08-14 12:59发布

On Internet Explorer 11, I have an issue with sub-pixel rendering causing an overflow of an element.

sub-pixel rendering error IE, Chrome, FireFox

As you can see, on IE11, the red part of the gauge seems to be "peeking" out of the bottom, while it seems fine on the other 2 major browsers Chrome and FireFox.

If we zoom in on the issue in IE, we can see what's happening:

sub-pixel rendering error IE, zoomed

It seems to be rendering a sub-pixel over the mask.
The header "Temperature" renders as an element with the height of 34.5px, causing all elements underneath it to be shifted .5px down, causing this issue.

This is how the gauge is built up: JSFiddle

<div id="temperature-gauge" class="gauge-control" data-percentage="0">
    <div class="header">Temperature</div>
    <div class="gauge-elements">
        <div class="gauge">
            <div class="inner"></div>
            <div class="spinner temp"></div>
        </div>
        <div class="pointer"></div>
        <div class="pointer-knob"></div>
    </div>
    <div class="indicator">60&deg; C</div>
</div>

Is there any way to solve this, other than giving the header a static height, to ensure all elements underneath are on a full-pixel?

3条回答
▲ chillily
2楼-- · 2019-08-14 13:37

Here's the best approach I think. We can avoid both IE bugs by combining the gauge's 3 colors into a single div, then transforming the whole thing. demo (the needle is still separate). It's simpler markup than your original way too.

查看更多
走好不送
3楼-- · 2019-08-14 13:59

I would recommend trying to set the line-height to the same as the font-size of the element, and make sure that both of these are integers and in pixels. Also try using pt instead of using px for font sizes to see if it helps.

查看更多
贼婆χ
4楼-- · 2019-08-14 14:03

Edge10162-border-radius-bug.png - Looks like it's here to stay for now. And here's Microsoft's official bullshit solution for the bugs. denial - Did you know MS censored the wrapper workaround from that msdn thread? What unethical jerks.


Alternate Solution

Don't defy Microsoft's skirting detection and obstructing workarounds by masquerading as Gecko+Webkit in their new UA-String.  When your users notice and object to the inferior quality (aka bugs), just point them to this msdn denial and this matching MS-Connect bookend.  And of course, this SO thread.

查看更多
登录 后发表回答