
For more Advanced Usages, please check the demo page or visit the official website. This awesome jQuery plugin is developed by PankajRasgania. Add the CSS class center-img-container to the image container and specify the height & width of an image. Download the plugin and load the JavaScript file centerImage.js after loading the latest jQuery library. It is not, however, works properly in Internet Explorer.ĬenterImage is a cross-browser, JavaScript (jQuery) solution to proportionally resize (stretch or crop depending on the image and container size) and center an image to fill its parent container with no distortion. The object-fit CSS property currently supports almost all modern browsers such as Chrome, Firefox, Safari, etc. Resize And Center An Image To Fill Its Container Using jQuery If the image's aspect ratio does not match the aspect ratio of its container, then the image will be clipped to fit.



