用jquery重现css3转换

时间:2011-09-08 01:24:49

标签: javascript jquery css css3 jquery-effects

嗨有没有人可以告诉我如何使用jquery使用一些延迟/动画速度来重现这个css3效果?

.element:hover{
-moz-transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
-webkit-transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
-o-transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
-ms-transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
z-index:9999;

}

JSFIDDLE

2 个答案:

答案 0 :(得分:2)

以下是我如何实现简单轮换(不考虑帧速率):

$(function(){
    (function(n){
        this.interval = n;
        this.transform = {
            'rotation': 0
        };

        this.start = function(){
            setInterval(this.update, this.interval);
        };

        this.update = function(){
            this.transform['rotation'] = (this.transform.rotation + 10) % 360;
            $('div').css('transform', 'rotate(' + this.transform.rotation + 'deg)');
        };
        return this;
    })(30).start();
});

http://jsfiddle.net/dbrecht/82aUL/1/

这演示了一个简单的动画。您应该能够弄清楚如何将其余部分组合在一起。

答案 1 :(得分:1)

这是一个接近你要求的东西。我相信你可以根据自己的喜好进行调整

$('.element').hover(function(){

    $(this).css('position','relative').animate({
        height: $(this).height()*1.3,
        width: $(this).width()*1.3,
        left: '-=' + $(this).width() /4,
        top: '-=' + $(this).height() /4,
        'fontSize': $('.element').css('fontSize').substring(0,$('.element').css('fontSize').length -2) * 1.3 + 'px'
    },'fast');
},
 function() {                 
       $(this).css('position','relative').animate({
        height: $(this).height()/1.3,
        width: $(this).width()/1.3,
        left: 0,
        top: 0,
        'fontSize': $('.element').css('fontSize').substring(0,$('.element').css('fontSize').length -2) / 1.3 + 'px'
    },'fast');
}            

);

http://jsfiddle.net/dTkhM/2/