davatron5000 / FitText.js

A jQuery plugin for inflating web type
http://fittextjs.com
6.76k stars 1.39k forks source link

Same font-size for all titles? #78

Closed Valeka closed 11 years ago

Valeka commented 11 years ago

Hi! Thanks for great plugin. I'm new with jQuery and I'm not so sure does it have to work this way. I used this plugin for the headings and it shrinks well long titles, but now all my titles on different pages, have the same size. I tried to use post class (which is different for all pages in Wordpress) but it is still the same. Is this how plugin should work or maybe I'm doing something wrong? Here is my code:

jQuery(document).ready(function(){ 
    jQuery('.postid-id .headings h2').fitText(1.9, { minFontSize: '31px', maxFontSize: '45px' }); 
});
davatron5000 commented 11 years ago

FitText applies itself to whatever you tell it to. I can't really visualize your problem without seeing a link to a live example. My guess is that if you remove the .postid-id bit from your selector, it'll probably work. I'd probably even scope it to .post h2, less selectors tend to work better.

Valeka commented 11 years ago

Thanks a lot for your very quick response. My bad, .postid was just example, because my php code inside js code was deleted somehow while I was sending this question. For example, for one post class was .postid-413, for the other post class was .postid-387 and so on. I don't have my site still online, but I just want to say that H2 on all my posts take the same size, even when I tried to mach unique selector (.postid-somenumber) for every single page. I hope that you have better insight now:)


Thanks again! I'm sorry if I wasn't clear enough. I will try to use BigText and compare my results. If I need to ask you something again I'll do it when I upload my site. Thanks a lot!

davatron5000 commented 11 years ago

take the same size

What do you mean by this? It's still unclear. Do you mean you want:

This is my Post Title

and

This is my super long post title with every word in the dictionary

to be the same width or font-size? FitText should be handling the font-size just fine. You don't need the post-id at all, you just need to target the selector h2 (or something similar). Again, I can't advise on this specifically because I can't see your website.

If you want them to be the same width, then you should should look at using BigText. FitText just makes text squeezy, BigText is awesome and designed to auto-size to a line.

UPDATE: Beyond this, I really can't contribute. This may be something you have to work on for a few days as you figure out JavaScript. I hate giving that advice but it might be the best answer in this case.