2016-05-23 79 views
-1

我想围绕中心点旋转文本(附加到滚动位置)。我不想要的东西是旋转和不可读的项目。他们应该走一圈路径。你有什么想法,我怎么能做到这一点?自旋文本围绕点的项目不带旋转

我为我的滚动动画使用Skrollr,但我对任何东西都是开放的。

starting position

rotate in progress

+0

整个元件顺时针旋转,并在同时,使内元件逆时针。 –

+0

工程完美。谢谢! – CaKa

回答

0

只是一个想法,你可以使用普通的CSS关键帧来实现这一目标。您可以在某个事件的父元素上触发一个类,并仅在应用此类时将动画设置为发生。我做了一个简单的片段来演示。不知道这是否会为你的情况做好工作。

@keyframes circle { 
 
    from { transform:rotate(0deg); } 
 
    to { transform:rotate(360deg); } 
 
} 
 

 
@keyframes inner-circle { 
 
    from { transform:rotate(0deg); } 
 
    to { transform:rotate(-360deg); } 
 
} 
 

 
.wrapper { 
 
    position: relative; 
 
    width: 400px; 
 
    height: 400px; 
 
    background-color: #CCCCCC; 
 
    border-radius: 50%; 
 
    font-size:12px; 
 
    animation: circle 5s linear infinite; 
 
} 
 

 
img { 
 
    width: 75px; 
 
    height: 75px; 
 
} 
 

 
.div1 { 
 
    position: absolute; 
 
    width:100px; 
 
    height:100px; 
 
    margin: 20px auto 0; 
 
    transform-origin:50% 50%; 
 
} 
 

 
.div2 { 
 
    position: absolute; 
 
    width:100px; 
 
    height:100px; 
 
    margin: 275px auto 0; 
 
    color:red; 
 
    transform-origin:50% 50%; 
 
} 
 

 
.div3 { 
 
    width:100px; 
 
    height:100px; 
 
    margin: 20px auto 0; 
 
    color:blue; 
 
    transform-origin:50% 200px; 
 
} 
 

 
.div4 { 
 
    width:100px; 
 
    height:100px; 
 
    margin: 20px auto 0; 
 
    color:green; 
 
    transform-origin:50% 200px; 
 
} 
 

 
div > div { 
 
    animation: inner-circle 5s linear infinite; 
 
}
<div class="wrapper"> 
 
    <div class="div1"> 
 
    <img src="https://cdn0.iconfinder.com/data/icons/star-wars/512/darth_vader-128.png" /> 
 
    <p> 
 
     This is some text lorem 
 
    </p> 
 
    </div> 
 
    <div class="div2"> 
 
    <img src="https://cdn0.iconfinder.com/data/icons/star-wars/512/darth_vader-128.png" /> 
 
    <p> 
 
     This is some text lorem 
 
    </p> 
 
    </div> 
 
</div>