我有,我希望有類似這種行爲的元素:動畫元素
也許是更容易使用這個GIF,但我的目標是使它通過腳本(或CSS),所以我想動畫像「gif」類似行爲的「立方體」。 到目前爲止,我實現了從左向右移動「立方體」,但是我無法找到解決方法,我可以在靠近中心時減慢「立方體」,並在離開中心時加速。
HTML:
<div class="holder">
<div class="cube">
</div>
</div>
CSS:
.holder{
position:relative;
width:400px;
}
.cube{
position:absolute; display:none;background: #48a548;
width: 10px; height: 10px;
}
的Jquery:
var width = $(".holder").width();
setInterval(function() {
$(".cube").fadeIn("fast").css({ left: "0%" }).animate(
{
left: "100%"
},
width).fadeOut("slow");
}, 2500);
個