JavaScript / jQuery: is it possible to change the font size to fill the given width?

I am writing an application, and in it I would like to have some h1 elements with a variable font size.

I use the full width (1000 pixels) of the div as a delimiter and a script that automatically sets the font of the h1 element so that it matches the width of the div without breaking the line.

This is pretty easy to do with php GD, but I thought I wanted to do this client side.

+3
source share
2 answers

TextFill jQuery, -

+2

, . , , , .

:

  • DIV jQuery, . element = $('element_id').clone()

  • font-size 1

  • ,

    • font-size
    • , .
    • ,

font-size .

: , @Pär, .

+2

Source: https://habr.com/ru/post/1738668/


All Articles