Skip to content

Instantly share code, notes, and snippets.

@firhome
Created April 15, 2013 08:18
Show Gist options
  • Select an option

  • Save firhome/5386650 to your computer and use it in GitHub Desktop.

Select an option

Save firhome/5386650 to your computer and use it in GitHub Desktop.
imgs
$(document).ready(function(){
var setting_img = function(dom_width,allimg,scale){
var dt_width = dom_width[0].offsetWidth;
if(scale){
var n1 = parseInt(scale.split(':')[0]),n2 = parseInt(scale.split(':')[1]);
var img_height = (dt_width / n1) * n2;
}else{
var img_height = 0;
};
var imgs = allimg;
imgs.each(function(i,d){
$(d).height(img_height);
});
};
//最新
setting_img($('#new > dt'),$('#new > img'),'3:4');
//最热
setting_img($('#hot > dt'),$('#hot > img'),'4:3');
$(window).resize(function(){
//最新
setting_img($('#new > dt'),$('#new > img'),'3:4');
//最热
setting_img($('#hot > dt'),$('#hot > img'),'4:3');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment