开发者

get jquery to return font-size in points

开发者 https://www.devze.com 2023-01-28 05:10 出处:网络
when I use .css(\'font-size\') in jquery, it returns the value in pixels, is there any way to making it to give it in points ? it\'s because I want to use it in php gd, and it requires the font size t

when I use .css('font-size') in jquery, it returns the value in pixels, is there any way to making it to give it in points ? it's because I want to use it in php gd, and it requires the font size to be in poi开发者_如何学运维nts


Try this:

var fontSize = ...
var points = parseInt(fontSize) * 72 / 96


If your font-size is defined in pt then you may access the fontSize property of element.style as follows...

var element = document.getElementById('my_element'),
    //return size as it is defined 
    fontSize = element.style.fontSize;


here is the above with a slight correction: (parseFloat($(this).css("font-size")) * 72.0 / 96.0).toFixed(2)

0

精彩评论

暂无评论...
验证码 换一张
取 消