我创建了一个动画微调器,使用"披萨片#34;由背景渐变。问题是我无法弄清楚起源应该是什么。动画继续跳跃。
查看小提琴: http://jsfiddle.net/eqc05bkf/
我怎样才能摆脱跳跃?
HTML:
<div class="slices bar">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
CSS:
.slices {
width:100px;
height:100px;
position:relative;
transform-origin: right bottom;
-webkit-animation: spin 2.8s infinite steps(8);
-moz-animation: spin 2.8s infinite steps(8);
-ms-animation: spin 2.8s infinite steps(8);
-o-animation: spin 2.8s infinite steps(8);
animation: spin 2.8s infinite steps(8);
}
.slices.bar div {
width: 100%;
height: 100%;
position: absolute;
top: 35px;
left: 45px;
border-radius: 50%;
background: linear-gradient(45deg, #CDCDCD 50%, transparent 50%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%;
transform-origin: 56px 52px;
/* container height / 2 */
}
@-webkit-keyframes spin {
to {
transform: rotate(1turn);
}
}
@-moz-keyframes spin {
to {
transform: rotate(1turn);
}
}
@-ms-keyframes spin {
to {
transform: rotate(1turn);
}
}
@keyframes spin {
to {
transform: rotate(1turn);
}
}
.slices.bar div:nth-child(1) {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
background: linear-gradient(45deg, red 50%, transparent 50%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%;
}
.slices.bar div:nth-child(2) {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.slices.bar div:nth-child(3) {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.slices.bar div:nth-child(4) {
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
.slices.bar div:nth-child(5) {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.slices.bar div:nth-child(6) {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
.slices.bar div:nth-child(7) {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
.slices.bar div:nth-child(8) {
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}
答案 0 :(得分:1)
我修改了你的代码。首先,我添加了一个容器div并简单地旋转它。 fiddle
HTML:
<div id='hold'>
<div class="slices bar">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
CSS:
.slices {
width:100px;
height:100px;
position:relative;
margin-top: -31px;
margin-left: -45px;
transform-origin: right bottom;
/*-webkit-animation: spin 2.8s infinite steps(8);
-moz-animation: spin 2.8s infinite steps(8);
-ms-animation: spin 2.8s infinite steps(8);
-o-animation: spin 2.8s infinite steps(8);
animation: spin 2.8s infinite steps(8);*/
}
#hold {
width: 112px;
height: 112px;
border-radius: 50%;
overflow: hidden;
-webkit-animation: spin 2.8s infinite steps(8);
-moz-animation: spin 2.8s infinite steps(8);
-ms-animation: spin 2.8s infinite steps(8);
-o-animation: spin 2.8s infinite steps(8);
animation: spin 2.8s infinite steps(8);
}
.slices.bar div {
width: 100%;
height: 100%;
position: absolute;
top: 35px;
left: 45px;
border-radius: 50%;
background: linear-gradient(45deg, #CDCDCD 50%, transparent 50%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%;
transform-origin: 56px 52px;
/* container height / 2 */
}
@-webkit-keyframes spin {
to {
transform: rotate(1turn);
}
}
@-moz-keyframes spin {
to {
transform: rotate(1turn);
}
}
@-ms-keyframes spin {
to {
transform: rotate(1turn);
}
}
@keyframes spin {
to {
transform: rotate(1turn);
}
}
.slices.bar div:nth-child(1) {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
background: linear-gradient(45deg, red 50%, transparent 50%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%;
}
.slices.bar div:nth-child(2) {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.slices.bar div:nth-child(3) {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.slices.bar div:nth-child(4) {
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
.slices.bar div:nth-child(5) {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.slices.bar div:nth-child(6) {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
.slices.bar div:nth-child(7) {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
.slices.bar div:nth-child(8) {
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}