anonicode
anonicode

Reputation: 317

How to make the text be smaller when overflow

I want the text to stay within one line,
so I want it to become smaller if there is a overflow.

I dont want to use ellipsis like the answer
that he (How can I make text get smaller in order to stay on one line?) got.

Upvotes: 1

Views: 786

Answers (1)

EugenSunic
EugenSunic

Reputation: 13693

   $(document).ready(function()
{
    $('#button').click(function() 
    {
    var current_size = $('#content_to_be_resized').css('font-size');
    var new_size = parseFloat(current_size) - 3;
    $('#content_to_be_resized').animate({fontSize: new_size}, 250);
    });
});

Suppose you click on a button you get you current size of the text and you make a new size using the parseFloat which actually parses a string and returns a floating point number, so in 20px – parseFloat() will return 20.

Upvotes: 1

Related Questions