使用jqthumb.js插件製作縮略圖
1.將下載好的jqthumb.js插件導入html
<script type="text/javascript" src="js/jqthumb.js"></script>
2.創建需要縮略圖顯示的圖片dom,並制定id
<img src="/img/test.png" id="testimg" />
3.js調用
$("#testimg").jqthumb({
classname: 'jqthumb', // 生成縮略圖的 div 類名. 默認是 jqthumb
width: '285px', // 剪裁後新圖片的寬度. 默認是 100px.
height: '210px', // 剪裁後新圖片的高度. 默認是 100px.
source: 'src', // 圖像資源的屬性. 默認 src.
show: true, // TRUE = 處理後立即顯示. FALSE = do not show it. DEFAULT IS TRUE.
// responsive: 20, // 只在舊的瀏覽器中使用. 0 to disable. DEFAULT IS 20
zoom: 1, // 放大倍數, 2 圖片實際大小的2倍. DEFAULT IS 1
method: 'auto', // 3 methods available: "auto", "modern" and "native". DEFAULT IS auto
});
jquery庫自行添加
4.效果
ps:相冊源碼可發郵箱