Heute zeige ich euch wie man so einen springenden Ball zeichnen und animieren kann.
Video
HTML
<div class="ball"></div>
CSS
:root {
--bg: #b4838d;
--ball: #f36725;
--rand: #000;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: var(--bg);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.ball {
position: relative;
height: 100px;
width: 100px;
background-color: var(--ball);
border-radius: 50%;
border: 1px solid var(--rand);
bottom: 30px;
animation: springen 800ms infinite;
}
@keyframes springen {
0% {
bottom: 25px;
}
25%,
75% {
bottom: 35px;
}
50% {
bottom: 40px;
}
100% {
bottom: 20px;
}
}







0 Kommentare