I have the following function to resize an image to fill its container div without skewing the image. It uses css to fill by height and if the image is not wide enough to fill the div then the function uses width to fill the div and sets height to auto. The problem is the code only works with window.load, so if the user is paying attention they can see the image load, then after a second it changes. So how would I change the function to work with document.ready?
function imageResize() {
$(".square").each(function(){
if($("img",this).width() < $(this).width()){
$("img",this).css("height", "auto");
$("img",this).css("width", "100%");
}
});
}
Aucun commentaire:
Enregistrer un commentaire