类似这样,飘忽不定的感觉
基本的写好了, 在控制台用图中的工具根据自己的需要调节一下
<div class="run-animation">
<style>
.run-animation {
width: 100px;
height: 100px;
position: absolute;
top: 100px;
left: 100px;
background-color: aquamarine;
animation: x-run 1.5s 0.1s linear infinite, y-run 1.5s 0.1s linear infinite;
/*
*animation: x-run 0.5s 0.1s linear, y-run 0.5s 0.1s cubic-bezier(.09,.66,.26,1.29);
*/
}
@keyframes x-run {
0% {
left: 100px;
}
50% {
left: 80px;
}
100% {
left: 100px;
}
}
@keyframes y-run {
0% {
top: 100px;
}
50% {
top: 50px;
}
100% {
top: 100px;
}
}
</style>
或者使用 CSS Motion Path:
https://codepen.io/Chokcoco/pen/gOgqoem
根据自己的需要改一下path