【发布时间】:2018-08-26 03:22:05
【问题描述】:
我用CSS3 创建了一个半圆,我会像图表一样使用它。
我的问题是我想为background-color 和rotate 制作动画。
最后,我希望看到这样的事情...... 这是 jsfiddle https://jsfiddle.net/wu1tbsne/28/
//FIRST BAR
$('#half-donut').addClass('first-start');
setTimeout(function() {
$('#half-donut').addClass('first-pause');
}, 1700);
body {
background-color: #000;
}
#half-donut {
width: 200px;
height: 100px;
background-color: #fff;
border-radius: 200px 200px 0% 0%;
margin-right: 3px;
display: flex;
justify-content: center;
align-items: flex-end;
}
#figlio {
width: 140px;
height: 75px;
background: #000;
border-radius: 140px 140px 0% 0%;
}
@keyframes first {
0% {
background-color: green;
}
33% {
background-color: yellow;
}
66% {
background-color: orange;
}
100% {
background-color: red;
}
}
.first-start {
animation: first 2s linear;
}
.first-pause {
animation-play-state: paused;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="half-donut">
<div id="figlio"></div>
</div>
最后我想看到这样的东西:
【问题讨论】:
-
你想为它制作动画吗?像速度计?
-
@emineminems 是的
-
别忘了添加 CSS 标签,否则我会错过你的问题:p
-
我删除了 Javascript 标签并添加了 CSS 标签 :)
-
@TemaniAfif 我解决了这个问题也感谢你的代码(动画 css3)
标签: jquery css css-animations keyframe