Closed maheshwaghmare closed 9 years ago
It's tough to see your issue without a proper reduced test case, but inline elements (like span
) don't have a width. https://github.com/davatron5000/FitText.js#css-faq
ex.fitText(Math.min(h,w)/Math.max(h,w), { minFontSize: '16px', maxFontSize: mf } ); });
That Math.min(h,w)/Math.max(h,w)
as your compressor value might be calculating as 0
(since inline elements don't have height/width) and that tells FitText to do nothing.
I'd probably just make child elements relative em
units.
Hi,
I was tried to apply FitText.js in nested element. Like below:
<span class="my_fitext">Good<span class="my_fitext">Luck</span></span>
or<span class="my_fitext">Good</span><span class="my_fitext">Luck</span>
I know it need width. There is any way to make responsive text on nested elements.
Also, Tried
<span class="my_fitext" data-font-size="70px">Good</span><span class="my_fitext" data-font-size="40px">Luck</span>
jQuery(".my_fitext").each(function(ind, elm) { var mf = jQuery(elm).attr('data-font-size'); var ex = jQuery(el); var h = ex.height(); var w = ex.width(); ex.fitText(Math.min(h,w)/Math.max(h,w), { minFontSize: '16px', maxFontSize: mf } ); });