Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to override "!important" #88

Open
yoannisj opened this issue Oct 25, 2013 · 2 comments
Open

Option to override "!important" #88

yoannisj opened this issue Oct 25, 2013 · 2 comments

Comments

@yoannisj
Copy link

Sometimes you may want to override css "!important" font-size rules. This can be done by replacing the resizer function by the following :

var resizer = function () {
      var fontSize = Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize));
      $this.attr('style', 'font-size: ' + fontSize + 'px !important');
};

The reason I wanted to do this is because I use a utility class to set fallback font-sizes, and, being part of a css framework, that utility class needs the !important flag.

http://css-tricks.com/when-using-important-is-the-right-choice/

There are probably some other use cases but I think it would be best to implement it as an option though.

@davatron5000
Copy link
Owner

Hrmmm... This is the first time this use case has come up. I think it's maybe unique to your situation where you want to use those utility classes with the !important flag. !important generally means "f&$%ing do this", so if an inline style from FitText can't style it, we probably want to yield. We could add an option, but the use case might be too small to justify it.

Because it's specific to your situation, I think you should just modify your version of FitText and use that. If this issue keeps cropping up, we'll reconsider adding an option.

@Drethic
Copy link

Drethic commented Nov 15, 2013

I ran into this exact situation and came up with almost the same fix as @yoannisj. Given that I'm building this into a WordPress plugin that can be used on various sites with many possible theme setups the option to override with important wouldn't be a bad thing and could be optional by adding a third option into the settings and if that's set use the .attr vs .css.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants