Preparation: Learning animate functions
Animate (Params,options)
A function to create a custom animation.
The key to this function is to specify the animation form and the result style Property object. Each property in this object represents a style attribute that can be changed (such as "height", "top", or "opacity").
Note: All specified attributes must be in camel form, such as marginleft instead of Margin-left.
The animation ends when the value of each property indicates how much of the style property is. If it is a numeric value, the Style property is graduated from the current value to the specified value. If you are using a string value such as hide, show, or toggle, the default animation form is invoked for the property.
Preparation: Learning animate functions
Animate (Params,options)
A function to create a custom animation.
The key to this function is to specify the animation form and the result style Property object. Each property in this object represents a style attribute that can be changed (such as "height", "top", or "opacity").
Note: All specified attributes must be in camel form, such as marginleft instead of Margin-left.
The animation ends when the value of each property indicates how much of the style property is. If it is a numeric value, the Style property is graduated from the current value to the specified value. If you are using a string value such as hide, show, or toggle, the default animation form is invoked for the property.
Start making: Zoom in on a picture
HTML code
| The code is as follows |
Copy Code |
<body> <div class= "Imagecontainer" > <div id= "ImageList" >
</div> </div> </body> |
CSS Code
| The code is as follows |
Copy Code |
. Imagecontainer{position:relative;height:200px;width:600px;background: #234} #imageList {height:200px; Position:absolute} #imageList img{height:100%;width:150px; position:absolute;} . img_1{left:0;} . img_2{left:150px;} . img_3{left:300px;} . img_4{left:450px;} |
/*
Description
In this example CSS plays a very important role, especially. Imagecontainer and #imagelist's position style of value, do not understand can be studied under the position relative and absolute role and the power of interaction.
*/
JS Code
| The code is as follows |
Copy Code |
$ ("#imageList img"). MouseOver (function () { $ (this). CSS ("Z-index", 99999); $ (this). Animate ({height: "150%", width:150 * 1.5}, {queue:false, duration:1500}); }). mouseout (function () { $ (this). Animate ({height: "100%", Width: "150px"}, {queue:false, duration:1000}); $ (this). CSS ("Z-index", 1); }); |
/* Description:
1. When the mouse moves to the IMG, the height and the width enlarge 1.5 times times, the animation time is 1500 milliseconds, the z-index biggest, guarantees the picture in the topmost
2. When the mouse moves out of the IMG, restore height and width, animation time of 1000 milliseconds, Z-index restore
*/