get jquery to return font-size in points

前端 未结 3 706
无人及你
无人及你 2020-12-11 22:12

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

相关标签:
3条回答
  • 2020-12-11 22:43

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

    0 讨论(0)
  • 2020-12-11 22:51

    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;
    
    0 讨论(0)
  • 2020-12-11 22:54

    Try this:

    var fontSize = ...
    var points = parseInt(fontSize) * 72 / 96
    
    0 讨论(0)
提交回复
热议问题