IE crossing out pseudo element CSS?

Kairowa picture Kairowa · Jan 10, 2015 · Viewed 58.2k times · Source

I've been trying to get a few pseudo elements to work on IE, but it just doesn't let me.

It crosses out the CSS and acts like it's not there, which kinda aggrevates me.

Would anyone know what I'm doing wrong?

Screenshot of what happens:

Answer

Sampson picture Sampson · Jan 10, 2015

This is a known issue, but the styles are in fact being applied. The developer tools thinks the pseudo-element styles are being overridden by the parent-elements corresponding styles. This is easily demonstrated by inspecting the Computed style of the parent-element and looking at (what the F12 tools believe to be) competing styles:

enter image description here

Again, however, these styles are in fact being applied to the correct elements - regardless what the developer tools believe or suggest. You can confirm this by running over the parent-element and the two pseudo-elements and logging their computed height:

(function () {

    var el = document.querySelector( ".newbutton" );

    [ "", "::before", "::after" ].forEach(function ( e ) {
        // Output: 74px, 80px, 80px
        console.log( window.getComputedStyle( el, e ).height );
    });

}());

I'll check to see if we already have an internal issue tracking this bug, and add this question to it. Generally speaking, we try to give issues like this the amount of attention proportional to the amount of grief the issue is causing in the real world. So having your question as a new addition on the ticket may help us move a fix forward :)