How to get the height of the line of flight?

Is there any way to get line-heightfor span(or another inline element) in JavaScript / jQuery?

I need an exact calculated line-heightin pixels , not sort values 1.2em, normalor type heuristics fontSize * 1.5.

What I need to do is stretch the background spanto fill the entire height of the line. I decided that I could add paddings to stretch the range, but for that I need the exact one line-height. If someone can suggest a different approach, this will also be helpful.

+5
source share
4 answers
$("span").css( "line-height");

px "16px", . IE currentStyle getComputedStyle . , , elem.style.something = value, .

+3

:

var style = window.getComputedStyle(element);
var lineHeight = style.getPropertyValue('line-height');

jQuery IE9 .

+2

, span div.

div : relative

span , 100% .

, .

( : , . div.)

0

, , , outerHeight...

var inlineHeight = $('.inline-height').css("display", "inline-block").outerHeight(); 
//console.log('Inline Height:' + inlineHeight);
0

All Articles