gpt4 book ai didi

html - CSS 中的@keyframe 动画问题

转载 作者:行者123 更新时间:2023-11-28 08:21:38 24 4
gpt4 key购买 nike

我在 CSS 中尝试了一个动画,但遇到了一个问题,它无法正常工作。这是我的 fiddle

ul {
display: block;
}
ul>li {
list-style-type: none;
transition: all 0.5s ease-out;
}
ul>li:nth-child(1) {
height:100px;
width: 100px;
background: transparent;
border-radius: 100%;
border:solid 5px #00f;
border-right: transparent;
border-left: transparent;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left:0;
margin: auto;
animation: spin 1s infinite ease-out;
}
ul>li:nth-child(2) {
height:75px;
width: 75px;
background: transparent;
border-radius: 100%;
border:solid 5px #0f0;
border-top: transparent;
border-bottom: transparent;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left:0;
margin: auto;
animation: spin2 1s infinite ease-out;
}
ul>li:nth-child(3) {
height:50px;
width: 50px;
background: transparent;
border-radius: 100%;
border:solid 5px #f00;
border-left: transparent;
border-right: transparent;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left:0;
margin: auto;
animation: spin3 1s infinite ease-out;
}
@keyframes spin1 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes spin2 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes spin3 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

最佳答案

添加browser prefixes而且您正在为第一个不存在的 li 使用动画名称旋转。

    ul {
display: block;
width: 200px;
height: 200px;
margin: 0 auto;
}
ul>li {
list-style-type: none;
}
ul>li:nth-child(1) {
height:100px;
width: 100px;
background: transparent;
border-radius: 100%;
border:solid 5px #00f;
border-right: transparent;
border-left: transparent;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left:0;
margin: auto;
-webkit-animation: spin1 5s infinite ease-out;
animation: spin1 5s infinite ease-out;
}
ul>li:nth-child(2) {
height:75px;
width: 75px;
background: transparent;
border-radius: 100%;
border:solid 5px #0f0;
border-top: transparent;
border-bottom: transparent;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left:0;
margin: auto;
-webkit-animation: spin2 5s infinite ease-out;
animation: spin2 5s infinite ease-out;
}
ul>li:nth-child(3) {
height:50px;
width: 50px;
background: transparent;
border-radius: 100%;
border:solid 5px #f00;
border-left: transparent;
border-right: transparent;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left:0;
margin: auto;
-webkit-animation: spin3 5s infinite ease-out;
animation: spin3 5s infinite ease-out;
}
@-webkit-keyframes spin1 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-webkit-keyframes spin2 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-webkit-keyframes spin3 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes spin1 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes spin2 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes spin3 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<ul>
<li></li>
<li></li>
<li></li>
</ul>

关于html - CSS 中的@keyframe 动画问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28735153/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com