Skip to content

zqstarmoon/jquery.imagefit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jQuery ImageFit 1.0.0

A simple, lightweight plugin to make images fit anywhere and anyway.

##Demo: right here

##Usage

Fist include the required files.

<script src='//code.jquery.com/jquery-1.10.2.min.js'></script>
<script src='jquery.imagefit.js'></script>

Then identify the elements you want to be affected. Let's say...

<div class="im"><img src="images/01.jpg" alt=""></div>
<div class="im"><img src="images/02.jpg" alt=""></div>
<div class="im"><img src="images/03.jpg" alt=""></div>
<div class="im"><img src="images/04.jpg" alt=""></div>
<div class="im"><img src="images/05.jpg" alt=""></div>
<div class="im"><img src="images/06.jpg" alt=""></div>

Finally set the ImageFit in the 'window load' event. If you detect visual flips or white margins then try doing it in both, the 'document ready' and the 'window load' events. There might be more accurate methods depending on how you apply the plugin.

$(window).load(function() {
	$('div.im').imagefit();
});

And that would be it.

##Reference

Option Type Default Description
mode string 'inside' It determines how images will be fitted inside the element: 'inside' or 'outside'.
halign string 'center' Horizontal alignment of the images relative to the container element: 'left', 'center' or 'right'.
valign string 'middle' Vertical alignment of the images relative to the container element: 'top', 'middle' or 'bottom'.
force bolean true Force resizing, even when image real size is smaller than container's.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%