导读:jQThumb 是在Web页面中创建按照一定比例显示缩略图的 jQuery 插件,使用 jQThumb 生成图片的缩略图可以避免不同尺寸的图片出现拉伸或...
jQThumb 是在Web页面中创建按照一定比例显示缩略图的 jQuery 插件,使用 jQThumb 生成图片的缩略图可以避免不同尺寸的图片出现拉伸或者压缩等失真现象,通过设置插参数,还可以控制显示图片的位置。 该插件兼容性强,甚至能在 IE6 和 jQuery v1.3 以上版本中正常工作。
jQThumb jQuery缩略图插件的使用方法:
- <!DOCTYPE html>
- <html>
- <body>
- <script type="text/javascript" src="scripts/jquery.min.js"></script>
- <script type="text/javascript" src="scripts/jqthumb.min.js"></script>
- <script type="text/javascript">
- $(function () {
-
-
- $('img').jqthumb({
- classname: 'jqthumb',
- width: '100%',
- height: '100%',
- position: {
- x: '50%',
- y: '50%'
- },
- source: 'src',
- show: false,
- responsive: 20,
- zoom: 1,
- method: 'auto',
- before: function (oriImage) {
- alert("I'm about to start processing now...");
- },
- after: function (imgObj) {
- console.log(imgObj);
- },
- done: function (imgArray) {
- for (i in imgArray) {
- $(imgArray[i]).fadeIn();
- }
- }
- });
-
-
- $('#kill').click(function () {
- $('.example1').jqthumb('kill');
- });
-
-
- $('#kill').click(function () {
- $.jqthumb('killall');
- });
- });
- </script>
- <div style="width: 100%; height: 400px;">
- <img src="path/picture.jpg" />
- </div>
- <div style="width: 400px; height: 400px;">
- <img src="path/picture.jpg" />
- </div>
- <button id="kill">Kill</button>
- <button id="kill-all">Kill All</button>
- </body>
- </html>
-
官方地址:
-
http://pakcheong.github.io/jqthumb/