Repository: davatron5000/FitText.js
Branch: master
Commit: 0b4183afb4c3
Files: 5
Total size: 6.8 KB
Directory structure:
gitextract_qz_cfngp/
├── CONTRIBUTING.md
├── README.md
├── bower.json
├── example.html
└── jquery.fittext.js
================================================
FILE CONTENTS
================================================
================================================
FILE: CONTRIBUTING.md
================================================
## Submitting issues
### Reduced test case required
All bug reports and problem issues require a reduced test case. See [CSS Tricks - Reduced Test Cases](http://css-tricks.com/reduced-test-cases/) on why they _"are the absolute, ... number one way to troubleshoot bugs."_
+ A reduced test case is an isolated example that demonstrates the bug or issue.
+ It contains the bare minimum HTML, CSS, and JavaScript required to demonstrate the bug. No extra functionality or styling.
+ A link to your site is **not** a reduced test case.
+ A [CodePen](http://codepen.io) is preferred so we can help you fix an error.
+ Until you provide a reduced test case, your issue will be closed.
This guideline may seem a little harsh, but it helps dramatically. Reduced test cases help you identify the issue at hand and understand your own code. On our side, they greatly reduce the amount of time spent resolving the issue.
================================================
FILE: README.md
================================================
# FitText.js, a jQuery plugin for inflating web type
FitText makes font-sizes flexible. Use this plugin on your responsive design for ratio-based resizing of your headlines.
## How it works
Here is a simple FitText setup:
```html
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.fittext.js"></script>
<script>
jQuery("#responsive_headline").fitText();
</script>
```
Your text should now fluidly resize, by default: Font-size = 1/10th of the element's width.
## The Compressor
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`.
```javascript
jQuery("#responsive_headline").fitText(1.2); // Turn the compressor up (resizes more aggressively)
jQuery("#responsive_headline").fitText(0.8); // Turn the compressor down (resizes less aggressively)
```
This will hopefully give you a level of "control" that might not be pixel perfect, but resizes smoothly & nicely.
## minFontSize & maxFontSize
FitText now allows you to specify two optional pixel values: `minFontSize` and `maxFontSize`. Great for situations when you want to preserve hierarchy.
```javascript
jQuery("#responsive_headline").fitText(1.2, { minFontSize: '20px', maxFontSize: '40px' });
```
## CSS FAQ
- :warning: Run FitText before anything that hides the element you're trying to size (e.g. before Carousels, Scrollers, Accordions, Tabs, etc). Hiding an element's container removes its width. It can't resize without a width.
- :warning: **Make sure your container has a width!**
- `display: inline` elements don't have a width. Use `display: block` OR `display: inline-block`+ a specified width (i.e. `width: 100%`).
- `position:absolute` elements need a specified width as well.
- Tweak until you like it.
- Set a No-JS fallback font-size in your CSS.
- :new: If your text is full width, you might want to **NOT** use FitText and just use CSS `vw` units instead. Supported in all major browsers.
## Don't use jQuery?
That's okay. Check out these handy non-jQuery versions maintained by other people.
- [non-jQuery FitText](https://github.com/adactio/FitText.js) from @adactio
- [Angular.js FitText.js](https://github.com/patrickmarabeas/AngularJS-FitText.js) from @patrickmarabeas
- [AMP-HTML FitText](https://github.com/ampproject/amphtml/tree/master/extensions/amp-fit-text)
- [FitText UMD](https://github.com/peacechen/FitText-UMD) by @peacechen
## Changelog
* `v 1.2` - Added `onorientationchange` event
* `v 1.1` - FitText now ignores font-size and has minFontSize & maxFontSize options
* `v 1.0.1` - Fix for broken font-size.
* `v 1.0` - Initial Release
## In Use:
- [Trent Walton](http://trentwalton.com)
If you want more exact fitting text, there are plugins for that! We recommend checking out [BigText](https://github.com/zachleat/BigText) by Zach Leatherman or [SlabText](https://github.com/freqDec/slabText) by Brian McAllister.
### Download, Fork, Commit.
If you think you can make this better, please Download, Fork, & Commit. We'd love to see your ideas.
================================================
FILE: bower.json
================================================
{
"name": "jquery-fittext",
"version": "1.2.0",
"main": "jquery.fittext.js",
"dependencies": {
"jquery": ">= 1.6"
},
"ignore": [
"example.html",
"CONTRIBUTING.md"
]
}
================================================
FILE: example.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>FitText</title>
<style type="text/css">
body {
background: #233a40;
color: #fff;
font: 16px/1.8 sans-serif;
}
.container {
width: 84%;
margin:0 auto;
max-width:1140px;
}
header {
width: 100%;
margin:0px auto;
}
h1 {
background: rgba(0,0,0,0.2);
text-align: center;
color:#fff;
font: 95px/1 "Impact";
text-transform: uppercase;
display: block;
text-shadow:#253e45 -1px 1px 0,
#253e45 -2px 2px 0,
#d45848 -3px 3px 0,
#d45848 -4px 4px 0;
margin: 5% auto 5%;
}
</style>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<div class="container">
<header>
<h1 id="fittext1">Squeeze with FitText</h1>
<h1 id="fittext2">Squeeze with FitText</h1>
<h1 id="fittext3">Squeeze with FitText</h1>
</header>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.fittext.js"></script>
<script type="text/javascript">
$("#fittext1").fitText();
$("#fittext2").fitText(1.2);
$("#fittext3").fitText(1.1, { minFontSize: '50px', maxFontSize: '75px' });
</script>
</body>
</html>
================================================
FILE: jquery.fittext.js
================================================
/*global jQuery */
/*!
* FitText.js 1.2
*
* Copyright 2011, Dave Rupert http://daverupert.com
* Released under the WTFPL license
* http://sam.zoy.org/wtfpl/
*
* Date: Thu May 05 14:23:00 2011 -0600
*/
(function( $ ){
$.fn.fitText = function( kompressor, options ) {
// Setup options
var compressor = kompressor || 1,
settings = $.extend({
'minFontSize' : Number.NEGATIVE_INFINITY,
'maxFontSize' : Number.POSITIVE_INFINITY
}, options);
return this.each(function(){
// Store the object
var $this = $(this);
// Resizer() resizes items based on the object width divided by the compressor * 10
var resizer = function () {
$this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
};
// Call once to set.
resizer();
// Call on resize. Opera debounces their resize by default.
$(window).on('resize.fittext orientationchange.fittext', resizer);
});
};
})( jQuery );
gitextract_qz_cfngp/ ├── CONTRIBUTING.md ├── README.md ├── bower.json ├── example.html └── jquery.fittext.js
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (8K chars).
[
{
"path": "CONTRIBUTING.md",
"chars": 913,
"preview": "## Submitting issues\n\n### Reduced test case required\n\nAll bug reports and problem issues require a reduced test case. Se"
},
{
"path": "README.md",
"chars": 3102,
"preview": "# FitText.js, a jQuery plugin for inflating web type\nFitText makes font-sizes flexible. Use this plugin on your responsi"
},
{
"path": "bower.json",
"chars": 193,
"preview": "{\n \"name\": \"jquery-fittext\",\n \"version\": \"1.2.0\",\n \"main\": \"jquery.fittext.js\",\n \"dependencies\": {\n \"jquery\": \">="
},
{
"path": "example.html",
"chars": 1717,
"preview": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>FitText</title>\n\n\t<style type=\"text/css\">\n\t\tbo"
},
{
"path": "jquery.fittext.js",
"chars": 1074,
"preview": "/*global jQuery */\n/*!\n* FitText.js 1.2\n*\n* Copyright 2011, Dave Rupert http://daverupert.com\n* Released under the WTFPL"
}
]
About this extraction
This page contains the full source code of the davatron5000/FitText.js GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (6.8 KB), approximately 2.1k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.