2013-12-10 31 views
0

我工作的一些基本使用COG动画CSS3 roating,CSS3动画 - 如何让动画确切地点

我的问题是齿轮围绕轻微地移动,并在一个准确的位置不留。

是否有可能将图像固定在一个点上,以免它们移动。

艾米帮助将是伟大的!

请参阅Fiddle

.container{ 
     background:black; 
} 
#cog-animation{ 
    height: 200px; 
    margin: 0 auto; 
    max-width: 380px; 
    position: relative; 
    margin-top: 30px; 
    } 

/* CSS3 keyframes */ 
@-webkit-keyframes ckw { 
    0% { 
     -moz-transform: rotate(0deg); 
     -webkit-transform: rotate(0deg); 
    } 
    100% { 
     -moz-transform: rotate(360deg); 
     -webkit-transform: rotate(360deg); 
    } 
} 
@-moz-keyframes ckw { 
    0% { 
     -moz-transform: rotate(0deg); 
     -webkit-transform: rotate(0deg); 
    } 
    100% { 
     -moz-transform: rotate(360deg); 
     -webkit-transform: rotate(360deg); 
    } 
} 
@-webkit-keyframes cckw { 
    0% { 
     -moz-transform: rotate(360deg); 
     -webkit-transform: rotate(360deg); 
    } 
    100% { 
     -moz-transform: rotate(0deg); 
     -webkit-transform: rotate(0deg); 
    } 
} 
@-moz-keyframes cckw { 
    0% { 
     -moz-transform: rotate(360deg); 
     -webkit-transform: rotate(360deg); 
    } 
    100% { 
     -moz-transform: rotate(0deg); 
     -webkit-transform: rotate(0deg); 
    } 
} 

/* gears */ 
.gear { 
    float: none; 
    position: absolute; 
    text-align: center; 

    -moz-animation-timing-function: linear; 
    -moz-animation-iteration-count: infinite; 
    -moz-animation-direction: normal; 
    -moz-animation-delay: 0; 
    -moz-animation-play-state: running; 
    -moz-animation-fill-mode: forwards; 

    -webkit-animation-timing-function: linear; 
    -webkit-animation-iteration-count: infinite; 
    -webkit-animation-direction: normal; 
    -webkit-animation-delay: 0; 
    -webkit-animation-play-state: running; 
    -webkit-animation-fill-mode: forwards; 

} 
#gear1 { 
    background: url('http://paulobriendesign.co.uk/images/g1.png') no-repeat 0 0; 
    height: 58px; 
    width: 58px; 
    left: 81px; 
    top: 25px; 
    -moz-animation-name: ckw; 
    -moz-animation-duration: 10s; 
    -webkit-animation-name: ckw; 
    -webkit-animation-duration: 10s; 
    } 
#gear2 { 
    background: url('http://paulobriendesign.co.uk/images/g2.png') no-repeat 0 0; 
    height: 85px; 
    left: 143px; 
    top: 36px; 
    width: 85px; 
    -moz-animation-name: cckw; 
    -moz-animation-duration: 16.84s; 
    -webkit-animation-name: cckw; 
    -webkit-animation-duration: 16.84s; 
} 
#gear3 { 
    background: url('http://paulobriendesign.co.uk/images/g3.png') no-repeat 0 0; 
    height: 45px; 
    width: 45px; 
    left: 218px; 
    top: 11px; 
    -moz-animation-name: ckw; 
    -moz-animation-duration: 13.5s; 
    -webkit-animation-name: ckw; 
    -webkit-animation-duration: 13.5s; 
} 

回答

2

背景图像偏离中心。

尝试添加: background-position:center;

1

的图像是不完美的正方形 - G1是54x53; g2是80x79; g3是39x38。

更大的问题是你的div比你的背景图片大。 #gear1是58x58,但图像只有54x53,所以有一些额外的空间使它看起来像div旋转时齿轮正在移动。