我有一個動畫這樣的:如何將JavaScript變量傳遞給我的CSS3動畫?
@-webkit-keyframes slideImg0
0%
background-position: center 0px
40%
background-position: center -50px
55%
background-position: center 50px
75%
background-position: center 500px
85%
background-position: center 510px
100%
background-position: center 500px
但我需要這個動畫是4倍不同的圖像略有不同。目前我已經有了slideImg1(它完全一樣,但所有像素值都是+500),slideImg2和slideImg2。浪費時間/空間,而且不可維護。
有沒有什麼辦法可以傳遞JavaScript的值來改變它?所以我可以去「運行所有值+ 500px的slideImg」?取而代之的
$(".heroImgWrapper").css("-webkit-animation", "slideImg" +counter + " 1s linear");
CSS3的速度要快得多。有相當數量的動畫正在進行,我不希望它減慢舊電腦的速度。 – morgoe 2013-04-30 00:57:11
我發現JQuery動畫在手機上很慢。我真的更喜歡使用CSS3。 – morgoe 2013-04-30 01:01:45
+1拒絕爲非必要的美容細節使用jQuery。 – 2013-04-30 01:02:52