欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery在頁面加載時(shí)動(dòng)態(tài)修改圖片尺寸的方法

 更新時(shí)間:2015年03月20日 10:55:27   作者:令狐不聰  
這篇文章主要介紹了jQuery在頁面加載時(shí)動(dòng)態(tài)修改圖片尺寸的方法,實(shí)例分析了jQuery操作圖片的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了jQuery在頁面加載時(shí)動(dòng)態(tài)修改圖片尺寸的方法。分享給大家供大家參考。具體如下:

$(window).bind("load", function() {
  // IMAGE RESIZE
  $('#product_cat_list img').each(function() {
    var maxWidth = 120;
    var maxHeight = 120;
    var ratio = 0;
    var width = $(this).width();
    var height = $(this).height();
    if(width > maxWidth){
      ratio = maxWidth / width;
      $(this).css("width", maxWidth);
      $(this).css("height", height * ratio);
      height = height * ratio;
    }
    var width = $(this).width();
    var height = $(this).height();
    if(height > maxHeight){
      ratio = maxHeight / height;
      $(this).css("height", maxHeight);
      $(this).css("width", width * ratio);
      width = width * ratio;
    }
  });
  //$("#contentpage img").show();
  // IMAGE RESIZE
});

希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論