简体   繁体   English

Javascript,Jquery或CSS3摆动字母动画

[英]Javascript, Jquery or css3 oscilating letter animation

i'm new in javascript and especially in animation. 我是JavaScript的新手,尤其是动画。 The challenge for me is to make a letter oscilate back and forth max 30 degrees from the sides. 我面临的挑战是使字母从侧面最大来回摆动30度。 The picture i uploaded is an example of the the animation, the letter will move from the upper right corner or from the pin but i think that is harder. 我上传的图片是动画的一个示例,字母将从右上角或从图钉移动,但我认为这很难。 I need some guidance into this if anyone can help please reply. 如果有人可以帮助,我需要一些指导,请回复。 Thanks in advance 提前致谢

because i'm new i cannot post images so here is the link: http://i.stack.imgur.com/byzUC.png 因为我是新手,所以我无法发布图像,因此,这里是链接: http : //i.stack.imgur.com/byzUC.png

Well, this took far longer than I care to admit, and is only reliable in (from my own limited testing) Chromium 12+ and Firefox 5+ on Ubuntu 11.04 (it does not work in Opera 11). 那么,这花了更长的时间比我愿意承认,并且仅在(从我自己有限的测试)铬12+和Firefox 5+在Ubuntu 11.04可靠的(它不能在Opera 11的工作)。 That being the case I'll show only the excerpts to cover Firefox and Chromium, though the linked JS Fiddle has vendor prefixes to at least try with Opera (even if it fails). 在这种情况下,尽管链接的JS Fiddle具有供应商前缀,至少可以尝试使用Opera(即使失败),但我只会显示Firefox和Chromium的摘录。 Using the following mark-up: 使用以下标记:

<img src="http://i.stack.imgur.com/byzUC.png" id="envelope" />

The following CSS produces an (infinitely) oscillating envelope for you to adjust to your preferences: 以下CSS会产生一个(无限)振荡的包络,供您调整以适应您的偏好:

#envelope {
 -webkit-animation-name: oscillate;
 -webkit-animation-duration: 10s;
 -webkit-animation-iteration-count: 10;
 -webkit-animation-direction: infinite;
 -moz-animation-name: oscillate;
 -moz-animation-duration: 10s;
 -moz-animation-iteration-count: 10;
 -moz-animation-direction: infinite;
}

@-webkit-keyframes oscillate {
    0% {
    -webkit-transform: rotate(0deg);
    -webkit-transform-origin: 108px 23px;
    }
    33% {
    -webkit-transform: rotate(15deg);
    -webkit-transform-origin: 108px 23px;
    }
    100% {
    -webkit-transform: rotate(-20deg);
    -webkit-transform-origin: 108px 23px;
    }
}

@-moz-keyframes oscillate {
    0% {
    -moz-transform: rotate(0deg);
    -moz-transform-origin: 110px 26px;
    }
    33% {
    -moz-transform: rotate(15deg);
    -moz-transform-origin: 110px 26px;
    }
    100% {
    -moz-transform: rotate(-20deg);
    -moz-transform-origin: 110px 26px;
    }
}

JS Fiddle demo . JS小提琴演示

Given the spectacular failure rate of this approach, though (it certainly doesn't work in Opera 11, and I can only imagine that it achieves nothing in IE...) I'd strongly suggest an animated gif for the sheer simplicity and cross-browser compliance. 鉴于这种方法的失败率很高(尽管它肯定在Opera 11中不起作用,而且我只能想象它在IE中什么也做不了...)我强烈建议使用动画gif,以实现简单和交叉-浏览器合规性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM