Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: about 2 months ago
JSON representation

jQuery plugin that allows you to fit elements (like images) within their containers.

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)