小球落入下方
const createBall = (left, top) => {
let Ball = document.createElement('div')
Ball.style.position = "absolute";
Ball.style.left = left + 'px'
Ball.style.top = top + 'px'
Ball.style.width = '20px'
Ball.style.height = '20px'
Ball.style.borderRadius = '50%'
Ball.style.backgroundColor = 'red'
Ball.style.transition = "left .6s linear, top .6s cubic-bezier(0.5, -0.5, 1, 1)";
document.body.appendChild(Ball);
setTimeout(() => {
Ball.style.left = Getcollect().offsetLeft + Getcollect().offsetWidth / 2 + "px";
Ball.style.top = 500 + "px";
}, 0);
Ball.ontransitionend = function () {
Ball.remove();
};
}
点击加号弹出减号,收起
.qiu-enter {
animation: enter 500ms linear;
}
@keyframes enter {
0% {
transform: translateX(38px) rotate(0deg);
opacity: 0;
}
100% {
transform: translateX(0px) rotate(-360deg);
opacity: 1;
}
}
.qiu-exit {
opacity: 0;
animation: exit 500ms linear;
}
@keyframes exit {
0% {
transform: translateX(0px) rotate(0deg);
opacity: 1;
}
100% {
transform: translateX(38px) rotate(360deg);
opacity: 0;
}
}