jQuery .css() function not returning expected values

前端 未结 7 1340
情歌与酒
情歌与酒 2020-12-31 08:10

Alright, I\'ve search the jQuery docs (needs somebody devoted to maintaining), I\'ve searched SO, and I\'ve searched Google. I can\'t find the answer to this question.

7条回答
  •  别那么骄傲
    2020-12-31 08:16

    This is not a complete answer to your question but it may be a working solution to caclulate the em values. I adapted this function from here. And here is the updated fiddle.

    $.fn.emWidth = function(){
        var wpx = this.width();
        var temp = $('
    ').css({ width:'1em', position: 'absolute' }); this.append(temp); var oneEm = temp.width(); temp.remove(); var value = wpx/oneEm; return Math.round(value*100)/100; };

提交回复
热议问题