2017-03-05 19 views
0

私はこれを作成しましたsnippet on Codepen:地球が回転して車が動いています。しかし、車が動くと、地球も回転します。私はすべての要素が自分たちの道を行くことを望む。2つのCSSアニメーションが互いに干渉します

なぜ車は地球に影響を及ぼしますか?どのように避けることができますか?

body { 
 
    background: url(https://news.vanderbilt.edu/files/NASA_SMBH1.jpg); 
 
    background-size: 1000px; 
 
} 
 

 
#firstimg { 
 
    background-image: url(http://www.21tech.ir/dfxhfgh.gif); 
 
    position: absolute; 
 
    background-repeat: no-repeat; 
 
    background-size: 100px; 
 
    animation: anim1 14s infinite linear; 
 
    margin: 40px; 
 
} 
 

 
#earth { 
 
    margin-left: 100px; 
 
    width: 500px; 
 
    height: 500px; 
 
    background: url(http://www.drodd.com/images14/map-of-earth1.jpg); 
 
    border-radius: 50%; 
 
    background-size: 1000px; 
 
    box-shadow: inset 16px 0 40px 6px rgb(0, 0, 0), inset -3px 0 6px 2px rgba(255, 255, 255, 0.2); 
 
    animation-name: rotate; 
 
    animation-duration: 30s; 
 
    animation-iteration-count: infinite; 
 
    animation-timing-function: linear; 
 
    filter: brightness(50%); 
 
} 
 

 
@keyframes rotate { 
 
    from { 
 
    background-position-x: 0px; 
 
    } 
 
    to { 
 
    background-position-x: 1000px; 
 
    } 
 
} 
 

 
@keyframes anim1 { 
 
    0%, 
 
    100% { 
 
    transform: translate(0, 0) rotate(0deg) 
 
    } 
 
    50% { 
 
    transform: translate(20px, 20px) rotate(10deg) 
 
    } 
 
}
<div id="firstimg"> 
 
    <div> 
 
    <div id="earth"></div>

答えて

1

あなたは、あなたのfirstimg divタグを閉じていないが故に、それは単一のdiv

<div id="firstimg"></div> 
<div id="earth"></div> 

フォローCodepen

下で実行されます
関連する問題