我创造了一个从角落开始的脉动动画。我希望它从圆圈的中心开始,下面是相同的css,我该怎么做才能从圆心开始动画。
.animation-container{width: auto; height: 500px;}
.aniCircle{width: 100px;height: 100px;border-radius: 50%;background: orange;margin: 0 auto;position: relative;top: 40%;animation: firstone 2s linear infinite alternate;-webkit-animation: firstone 2s linear infinite alternate;}
@-webkit-keyframes firstone{
0% {width:0px; height: 0px; background: violet;}
10%{width: 10px; height: 10px;background: indigo;}
20%{width: 20px; height: 20px; background: blue;}
30%{width: 30px; height: 30px; background: green;}
40%{width: 40px; height: 40px; background: yellow;}
50%{width: 50px; height: 50px; background: orange;}
60%{width: 60px; height: 60px; background: orange;}
70%{width: 70px; height: 70px; background: red;}
80%{width: 80px; height: 80px; background: orange;}
90%{width: 90px; height: 90px; background: yellow;}
100%{width: 100px; height: 100px; background: green;}
}
以下是codepen的链接:http://codepen.io/SurajVerma/pen/igxyr
感谢。
答案 0 :(得分:2)
<强> SOLUTION 强>
CSS更改:
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
段:
.animation-container{width: auto; height: 500px;}
.aniCircle{width: 100px;height: 100px;border-radius: 50%;background: orange;position: absolute;top: 50%;left: 50%; transform: translate(-50%, -50%);animation: firstone 2s linear infinite alternate;-webkit-animation: firstone 2s linear infinite alternate;}
@-webkit-keyframes firstone{
0% {width:0px; height: 0px; background: violet;}
10%{width: 10px; height: 10px;background: indigo;}
20%{width: 20px; height: 20px; background: blue;}
30%{width: 30px; height: 30px; background: green;}
40%{width: 40px; height: 40px; background: yellow;}
50%{width: 50px; height: 50px; background: orange;}
60%{width: 60px; height: 60px; background: orange;}
70%{width: 70px; height: 70px; background: red;}
80%{width: 80px; height: 80px; background: orange;}
90%{width: 90px; height: 90px; background: yellow;}
100%{width: 100px; height: 100px; background: green;}
}
@-moz-keyframes firstone{
0% {width:0px; height: 0px; background: violet;}
10%{width: 10px; height: 10px;background: indigo;}
20%{width: 20px; height: 20px; background: blue;}
30%{width: 30px; height: 30px; background: green;}
40%{width: 40px; height: 40px; background: yellow;}
50%{width: 50px; height: 50px; background: orange;}
60%{width: 60px; height: 60px; background: orange;}
70%{width: 70px; height: 70px; background: red;}
80%{width: 80px; height: 80px; background: orange;}
90%{width: 90px; height: 90px; background: yellow;}
100%{width: 100px; height: 100px; background: green;}
}
&#13;
<div class="content animation-container">
<div class="aniCircle"></div>
</div>
&#13;