Images will be available for a lot of time, especially in articles, right? If we fix the image size, it will be distorted, affecting the appearance, now let's take a practical use of jquery to control proportional scaling Code such as images. Of course, this is only a method to proportional scaling the image size, as well as css and js.
Images will be available for a lot of time, especially in articles, right? If we fix the image size, it will be distorted and affect the appearance. Now we can use jquery to control images and so on.Proportional ScalingCode, of course, this is onlyProportional ScalingA Method of size, including css tutorials and webpage special effects.
Jquery. fn. autozoomloadimage = function (scaling, width, height, loadpic ){
If (loadpic = null) loadpic = "loading.gif ";
Return this. each (function (){
Var t = $ (this );
Var src = $ (this). attr ("src ");
Var img = new image ();
// Alert ("loading ")
Img. src = src;
// Auto Scaling
Var autoscaling = function (){
If (scaling ){
If (img. width> 0 & img. height> 0 ){
If (img. width/img. height> = width/height ){
If (img. width> width ){
T. width (width );
T. height (img. height * width)/img. width );
}
Else {
T. width (img. width );
T. height (img. height );
}
}
Else {
If (img. height> height ){
T. height (height );
T. width (img. width * height)/img. height );
}
Else {
T. width (img. width );
T. height (img. height );
}
}
}
}
}
// The cached image is automatically read under ff.Proportional scaling of jquery ImagesProgram
If (img. complete ){
// Alert ("gettocache! ");
Autoscaling ();
Return;
}
$ (This). attr ("src ","");
Var loading = $ (" ");
T. hide ();
T. after (loading );
$ (Img). load (function (){
Autoscaling ();
Loading. remove ();
T. attr ("src", this. src );
T. show ();
// Alert ("finally! ")
});
});
}