Thursday, November 17, 2011

jQuery Image Resize in aspect ratio


If you are looking for resize image as per its parent block and it must maintain aspect ratio?
jquery plugin “Aspect Ratio”. It fit image to parent container
e.g. suppose i have an  
having ID as container. all the images
should be resized as per the width of the
and images should
maintain it’s aspect ration too.
  1. Add the jquery library to your page.
  2. Add the Dimensions plugin to the page – http://plugins.jquery.com/project/dimensions
  3. Finally, Add the Aspect Ratio plugin to the page.
To manipulate all images on a page w/ the AspectRatio plugin, simply type…
$(‘img’).AspectRatio();

No comments: