This time I will share jQuery Plugin and tutorial about jQuery Plugin To Fit An Elements Within Its Container – fittable, hope it will help you in programming stack.
File Size: | 3.93 KB |
---|---|
Views Total: | 410 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
fittable is a tiny and simple-to-use jQuery plugin that automatically scales, crops and re-positions an element (e.g. images and videos) to fit within its parent container, while maintaining the original aspect ratio.
How to use it:
1. Load jQuery library and the jQuery fittable plugin just right before the closing body tag.
1 |
< script src = "//code.jquery.com/jquery.min.js" ></ script > |
2 |
< script src = "jquery.fittable.js" ></ script > |
2. Assume that you have an image inside the DIV container ‘.box’.
1 |
< div class = "box" > |
2 |
< img class = "image-fit" src = "1.jpg" width = "640" height = "480" > |
3 |
</ div > |
3. Call the function on the image and the plugin will do the rest.
1 |
$( '.image-fit' ).fit(); |
This awesome jQuery plugin is developed by thomasmarshall. For more Advanced Usages, please check the demo page or visit the official website.
source : jqueryscript.net