https://github.com/magiclen/fit-html-text
Fit text into its surrounding container.
https://github.com/magiclen/fit-html-text
html typescript
Last synced: 4 months ago
JSON representation
Fit text into its surrounding container.
- Host: GitHub
- URL: https://github.com/magiclen/fit-html-text
- Owner: magiclen
- License: mit
- Created: 2023-03-28T08:40:38.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-22T03:39:13.000Z (over 1 year ago)
- Last Synced: 2025-03-24T17:55:19.597Z (about 1 year ago)
- Topics: html, typescript
- Language: JavaScript
- Homepage:
- Size: 430 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
fit-html-text
==========
[](https://github.com/magiclen/fit-html-text/actions/workflows/ci.yml)
Fit text into its surrounding container.
## Usage
```typescript
import { fitText } from "fit-html-text";
const element = document.getElementById("myElement");
fitText(element, {
fontMinSize: 8,
fontMaxSize: 72,
containerMaxWidth: 300,
containerMaxHeight: 300,
multipleLines: false,
});
```
## Usage for Browsers
[Source](demo.html)
[Demo Page](https://rawcdn.githack.com/magiclen/fit-html-text/master/demo.html)
## License
[MIT](LICENSE)