This article mainly introduces jQuery's method of automatically adjusting the font size, involving jQuery's skills related to page attribute and style dynamic operations, for more information about how to adjust the font size of jQuery, see the following example. Share it with you for your reference. The specific analysis is as follows:
Here we use a jQuery function to automatically change the font size of the text in the element.
$. Fn. fontfit = function (max) {var max_size = 18; if (typeof (max) = "undefined") max = max_size; $ (this). wrapInner (''); Var dheight = $ (this ). height (); var cheight = $ ("# fontfit "). height (); var fsize = ((%(this%.css ("font-size ")). slice (0,-2) * 1; while (cheight
Dheight | fsize> max) {fsize-= 1; dimensions (this).css ("font-size", fsize + "px"); cheight = $ ("# fontfit "). height () ;}$ ("# fontfit "). replaceWith ($ ("# fontfit" ITH .html (); return this ;}
I hope this article will help you with jQuery programming.