Naser Yousefi Naser Yousefi - 1 month ago 5
CSS Question

How can I get absolute line-height when it set to 'normal'?

I have this:

<p id="p1" style="line-height:normal">
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>


and I need to increment line-height one pixel.
How can I get absolute line-height when it set to 'normal'?

ar lh=$('#paraph').css('line-height');

Answer

OK finally I write this code and it's work properly in chrome

$('#lineHeightInc')
    .click(function() {
        var box = GetSelectedBox();
        var ct = box.data('LineHeight');
        if (isNaN(ct))
            ct = 0;
        ct++;
        box.css('line-height', (parseFloat(box.css('font-size')) * 1.61 + ct) + 'px');
        box.data('LineHeight', ct);
    });
$('#lineHeightDic')
    .click(function () {
        var box = GetSelectedBox();
        var ct = box.data('LineHeight');
        if (isNaN(ct))
            ct = 0;
        ct--;
        box.css('line-height', (parseFloat(box.css('font-size')) * 1.61 + ct) + 'px');
        box.data('LineHeight', ct);
    });

If any one has better solution I would be happy to know that.