- This topic is empty.
Viewing 15 posts - 1 through 15 (of 15 total)
Viewing 15 posts - 1 through 15 (of 15 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › FitText.js not working?
I can’t get this guy to work to save my life. I feel like it’s something really really simple that I’m not seeing.
It works for me in DevTools.
You’re missing ;
at the end of fitText()
The semicolon is not needed according to the source code. However, it doesn’t seem to work. My text is not resizing to fit the width of the container.
I had to set it as .31 in the script. It works now. Thanks!
Why .31
, seems like a very random number.
I thought fitText();
would do that auto-magically, without passing anything.
I’m not sure why but it states this in the docs.
If your text is resizing poorly, you’ll want to turn tweak up/down “The Compressor”. It works a little like a guitar amp. The default is 1.
I just confirmed this on my local machine. fitText(); should just work.
css …
.wrapper { width:800px; }
html
<div class="wrapper">
<h1 class="h1">My fitText title</h1>
</div>
script
$('.h1').fitText();
Could it be that you’re using it on p
instead of h1
etc…?
I don’t think so. In the demo, they are using spans and it still works without setting the ‘Compressor’.
Yeah I’m not fond of fitText so not much experience with it. Including JavaScript lib just to make text bigger, idk… much rather control it with CSS.
http://vimeo.com/68910118 start at 31 mark Remy has a great point about the library.
Awesome. I wonder what the Paravel team had to say about it.
Well I figured out what was happening with my code. Turns out you haveto call fittext at the botom of the page, after the text has loaded. otherwise the heading doesn’t actually exist when jQuery looks for it.