Full Bleed Image Resize Calculation
问题 Hey Guys, I'm trying to write a JavaScript function that will expand an image to fill a div always (so crop top or sides as needed). It's the JavaScript equivalent of the CSS3 code background-size: cover. I can't for the life of me figure it out. This is what I have so far: function full_bleed(box_width, box_height, new_width, new_height) { var aspect_ratio=new_width/new_height; if(new_height<box_height) { new_height=box_height; new_width=Math.round(new_height*aspect_ratio); } if(new_width