那些年我追过的代码

1.瀑布流

 1 /*var imgResize = function ()
 2 {
 3     var picList = document.getElementById("piclist").getElementsByTagName("img")
 4     for(i=0;i<picList.length;i++){
 5         //if(picList[i].width <= 90 && picList[i].height <= 120) continue;
 6         try
 7         {
 8             var v1 = picList[i].width / picList[i].height;            
 9         }
10         catch (e)
11         {
12             var v1 = 1;
13         }    
14         if(v1 > 90 / 120)
15         {
16             picList[i].height = Math.floor(90 / v1);
17             picList[i].width = 90;
18         }
19         else
20         {
21             picList[i].height = 120;
22             picList[i].width = Math.floor(120 * v1);
23         }    
24     }
25 };
26 
27 var _imgResize = new imgResize();*/
28 
29 function ResizeImage(imgObj)
30 {
31     var v1 = imgObj.clientWidth / imgObj.clientHeight;
32     if(v1 > 120/120)
33     {
34         imgObj.style.height = 120/ v1 + "px";
35         imgObj.style.width = "120px";
36     }
37     else
38     {
39         imgObj.style.height = "120px";
40         imgObj.style.width = 120 * v1 + "px";
41     }
42 }

 

posted @ 2016-05-05 14:36  苹果砸不中  阅读(112)  评论(0)    收藏  举报