Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rtheunissen/tailorfit
jQuery plugin that allows you to fit elements (like images) within their containers.
https://github.com/rtheunissen/tailorfit
Last synced: 5 days ago
JSON representation
jQuery plugin that allows you to fit elements (like images) within their containers.
- Host: GitHub
- URL: https://github.com/rtheunissen/tailorfit
- Owner: rtheunissen
- License: mit
- Created: 2013-04-13T03:58:06.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-08T02:25:57.000Z (over 9 years ago)
- Last Synced: 2024-10-28T13:11:08.108Z (16 days ago)
- Language: JavaScript
- Size: 1000 KB
- Stars: 18
- Watchers: 5
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE.txt
Awesome Lists containing this project
README
# TailorFit
## Positioning plugin that supports arbitrary expressions
#### Usage
```js
$('#parent > img').load(function(){
// maxWidth, maxHeight, maintain aspect ratio
$(this).tailorfit({
maxWidth : this.width,
maxHeight : this.height,
ratio : this.width / this.height
});
});
```You can also use expressions to evaluate a value.
For example: `max-width: 0.8*w-(200-h/4)` or `max-width: h / 2 - 20`, where `w` and `h` are the parent's width and height.
Note: `(expr) = expression, using (w, h, +, -, *, /, ^, %)`
### Available options:
* max-width (expr)
* max-height (expr)
* aspect-ratio (expr)
* x-offset (expr)
* y-offset (expr)
* h-position (left | center | right)
* v-position (top | center | bottom)
* rounding-method (round | floor | ceiling)
* overflow (contain | crop)