javascript - How to get the real height of a text? -
referring go example
http://jsfiddle.net/uzgjx/
the result height of box containing text (the 1 can see if select text mouse..) wichi higher real height of text.
there way real height jquery or plain js?
in example tryed with
text.height() and
text[0].getboundingclientrect().height with no luck, says 19px instead of 14px
get computed font-size text element instead:
parseint(window.getcomputedstyle(text[0]).fontsize, 10); font-size represents size of em square font. should noted that, while glyphs stay inside bounds of em square, may exceed bounds. doesn't occur on vertical dimentions, though.
give try: http://jsfiddle.net/uzgjx/1/. tip: screenshot , copy favourite image editor, select pixels height of text , compare value given in fiddle.
Comments
Post a Comment