如何调整球旋转半径的大小,使其接触橙色容器边框
.bg {
background-color: blue;
display: flex;
align-items: center;
justify-content: center;
}
.ball-container {
position: relative;
display:flex;
justify-content:center;
align-items:center;
background-color: orange;
width: 250px;
height: 250px;
}
.ball {
position: absolute;
width: 24px;
height: 24px;
background-color: white;
border-radius: 50%;
top: 125px - 12px;
left: 125px - 12px;
animation-name: ball_moves;
animation-duration: 1.5s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-direction: initial;
}
.ball:nth-child(1) {
transform-origin: top left;
}
.ball:nth-child(2) {
transform-origin: top right;
}
.ball:nth-child(3) {
transform-origin: bottom left;
}
.ball:nth-child(4) {
transform-origin: bottom right;
}
@keyframes ball_moves {
0% {
transform: rotateZ(0);
}
100% {
transform: rotateZ(360deg);
}
}
<div class="bg">
<div class="ball-container">
<div class="ball"></div>
<div class="ball"></div>
<div class="ball"></div>
<div class="ball"></div>
</div>
</div>
慕婉清6462132
相关分类