This time I will share jQuery Plugin and tutorial about jQuery Plugin To Maintain Element Aspect Ratios – maintainratio, hope it will help you in programming stack.
maintainratio is a lightweight jQuery plugin which can be used to maintain the aspect ratio of an element (e.g. div) as the window resizes.
How to use it:
1. Link to jQuery library and the jQuery maintainratio plugin.
1 |
< script src = "//code.jquery.com/jquery.min.js" ></ script > |
2 |
< script src = "jquery.maintainratio.js" ></ script > |
2. Call the function on the target element and specify the aspect ratio you prefer.
1 |
$( '.div' ).maintainRatio({ |
3. Set an offset in pixels to the element.
1 |
$( '.div' ).maintainRatio({ |
This awesome jQuery plugin is developed by davidjohnfarmer. For more Advanced Usages, please check the demo page or visit the official website.