getComputedStyle from the before pseudo element

I am trying to get the computed style from a :before selector of an element.

I have tried this, but it’s not working, how can I make this work?

var a = window.getComputedStyle(document.querySelector('#one:before'), null);


According to MDN, the second parameter to the .getComputedStyle() method is the pseudo element:

var style = window.getComputedStyle(element[, pseudoElt]);

pseudoElt (Optional) - A string specifying the pseudo-element to match. Must be omitted (or null) for regular elements.

Therefore you should use the following:

var a = window.getComputedStyle(document.querySelector('#one'), ':before');

Updated Example