2026/01/28
keyframeアニメーション
@charset “utf-8”;
/* CSS Document */
body {
background-color:red;
height:100vh;
position:relative;
padding: 0;
margin: 0;
}
.ptnBox {
display:table-cell;
width: 100px;
height:100px;
background-color:transparent;
position:absolute;
left:0;
top: 50%;
transform:translateY(-50%);
animation-name: animeX;
animation-duration: 8s;
animation-iteration-count:infinite;
animation-fill-mode: forwards;
animation-timing-function: linear;
}
.ptnInBox {
position:absolute;
display: table-cell;
width:100px;
height:100px;
background-color:yellow;
border-radius: 50px;
animation-name: animeY;
animation-duration: 2s;
animation-iteration-count:infinite;
animation-fill-mode: forwards;
animation-timing-function: linear;
}
@keyframes animeX {
0%{
left:0vw;
}
50%{
left:90vw;
}
100%{
left:0vw;
}
}
@keyframes animeY {
0% {
top:0;
}
25% {
top:300px;
}
50% {
top:0;
}
75% {
top:-300px;
}
100% {
top:0;
}
}