html - javascript: get height of pseudo :before element -


i need height of pseudo :before element. sounds no-brainer, cannot work. have tried:

$('.test:before').height() // --> null 

and jsfiddle suggestions wrong ?

update: height of .test depends on content. need is, when height gets bigger pseudo element, need add padding right of element. however, because height of pseudo element set css don't know in program

super-late reply, but: can use vanilla javascript pseudo-element dimensions using getcomputedstyle method:

var testbox = document.queryselector('.test');  // or jquery: testbox = $('.test').get(0); - want js element, without jquery wrapper  var pseudobeforeheight = window.getcomputedstyle(testbox, ':before').height; // returns (string) "70px" 

this return string of pixel value, regardless of css declaration (e.g. 4.375rem = 70px, 10vh = 70px, calc(8vh + 1rem) = 70px, number (in pixels) can do:

var pseudoheightnum = parseint(pseudobeforeheight);

with regards compatibility: caniuse suggests that, of july 2017 works pretty across in modern browsers (apparently support ie9 , above): reference.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -