是否可以为缩放css属性设置动画

时间:2011-11-07 10:16:53

标签: jquery css animation zoom zooming

是否可以为缩放动画设置动画

我试过这个,但它和使用css属性设置它一样。

$(this).animate({
    zoom: 0.5
}, 500);

高度动画等工作

2 个答案:

答案 0 :(得分:9)

试试这个:

-moz-transform: scale(2); 
-webkit-transform: scale(2);
-o-transform: scale(2);

**,但目前你无法使用基本的jQuery为它们制作动画。

但是,您可以使用jQuery插件,例如jquery.transform.js.

请注意IE9也支持transform属性,我在this SO question. **

中找到了一些相关信息。

答案 1 :(得分:-4)

你甚至可以用jQuery这样做:

jQuery(this).hover(function() {
        jQuery(this).animate({
                marginTop: '-10px', //Bring image to top a little bit
                marginLeft: '-10px',
                width: '30px', //Zoom by 30 px
                height: '30px' 
            }, 500); /* 500 is the speed of how fast/slow image animates */

        } , function() {
        jQuery(this).animate({
                width: '15px', //Bring image back to original size
                height: '15px'
            }, 500);
    });