I am trying to zoom in some images to fit into the window if the height of images are less using Transform in CSS.
But as my images are of different height uploaded by the users of my website so just by giving following css code its not zooming enough for different Images.
CSS
.small{
transform:scale(1.42,1.42);
-webkit-transform:scale(1.42,1.42);
-moz-transform: scale(1.42,1.42);
-o-transform: scale(1.42,1.42);
-ms-transform: scale(1.42,1.42);
/*transition: all 0.65s;
-webkit-transition: all 0.65s;
-moz-transition: all 0.65s;
-o-transition: all 0.65s;
-ms-transition: all 0.65s;*/
}
So now I wanted to add the scale value of transform dynamically using JS . What I have done till now is the following script
SCRIPT
function imageHandler() {
var images = $('.rslides ').find('img');
$('.rslides ').find('#bg').addClass('thumbnail');
setTimeout(function () {
images.each(function () { // jQuery each loops over a jQuery obj
var mh=290;
var h = $(this).innerHeight(); // $(this) is the current image
if( h < mh)
{
$(this).addClass('small');
var m = mh-h;
m = m/2;
// m = m + pginationH;
$(this).css('margin-top', +m + "px");
console.log("padding for small:",m);
}
if(h > mh)
{
$(this).addClass('big');
var m = h-mh;
m = m/2;
//console.log(m);
$('.big').css('margin-top',-m +"px" );
console.log("padding for big:",m);
}
});
}, 1000);
}
The above script maps the image and add class .small if the height is less than 290 . So what I want to do is add Transform scale value according to the height of the image
Can any one help me out with this
Thanks in advance