jQuery Plugin To Maintain Element Aspect Ratios - maintainratio
| File Size: | 3.85 KB |
|---|---|
| Views Total: | 777 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
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.
<script src="//code.jquery.com/jquery.min.js"></script> <script src="jquery.maintainratio.js"></script>
2. Call the function on the target element and specify the aspect ratio you prefer.
$('.div').maintainRatio({
ratio: 1
});
3. Set an offset in pixels to the element.
$('.div').maintainRatio({
ratio: 1,
pixelmod: 0
});
This awesome jQuery plugin is developed by davidjohnfarmer. For more Advanced Usages, please check the demo page or visit the official website.











