Trouble with the Moons Orbit


#1

Hello there I am having trouble getting my moon to orbit my Earth. Currently it is following the same orbit as the Earth but is lagging a second or two behind it. Any help you could offer would be greatly appreciated. I will post my code down below.

Here is my index.html

<html>
    <head>
        <link rel="stylesheet" href="style.css" />
    </head>
    
    <body>
    
        <!-- Right below is an image of the sun -->
        <img id="sun" src="http://pre10.deviantart.net/c764/th/pre/f/2011/264/1/e/a_sun_by_ephemeralblue-d4aibvk.png">
        
        <!-- Insert the 'earth' on the next line -->
        <div id='earth-orbit'>
            <img id="earth" src="http://4.bp.blogspot.com/-Y7wLC_VU_14/VPYQFu5DjeI/AAAAAAAAEiI/P9Pf2ehFS6g/s1600/earth%2B%281%29.png">
            
            <div id='moon-orbit'>
        <img id="moon" src="http://orig01.deviantart.net/5876/f/2013/268/f/3/71546_eclipse256_by_shinikami1-d6ns5l7.png">
        </div>
            
        </div>
        
    </body>
</html>

and** here is my style.css**

html, body {
    /* The universe takes up all available space */
    width: 100%;
    height: 100%;
    
    /* The universe is black */
    background-color: black;
}

#sun {
    position: absolute;
    /* Positions the top-left corner of the image to be *
    /* in the middle of the box */
    top: 50%;
    left: 50%;
    
    /* Play with these numbers to see what it does */
    height: 200px;
    width: 200px;
    margin-top: -100px; 
    margin-left: -100px;
    
}

#earth {
    /* Style your earth */
    position: absolute;
    top: 0%;
    left: 50%;
    
    height: 50px;
    width: 50px;
    margin-left: -25px;
    margin-top: -25px;
    
}

#moon {
    /* moon style */
    position: absolute;
    top: 0%;
    left: 50%;
    
    height: 30px;
    width: 30px;
    margin-left: -10px;
    margin-top: -10px;
}

#earth-orbit {
    /* For Section #2 */
    position: absolute;
    top: 50%;
    left: 50%;
    
    width: 500px;
    height: 500px;
    margin-top: -250px;
    margin-left: -250px;
    
    border-width: 2px;
    border-style: dotted;
    border-color: white;
    border-radius: 50%;
    
  -webkit-animation: spin-right 10s linear infinite;
     -moz-animation: spin-right 10s linear infinite;
      -ms-animation: spin-right 10s linear infinite;
       -o-animation: spin-right 10s linear infinite;
          animation: spin-right 10s linear infinite;
}

#moon-orbit {
    
     position: absolute;
    top: 55%;
    left: 55%;
    
    width: 100px;
    height: 100px;
    margin-top: -250px;
    margin-left: -250px;
    
    border-width: 2px;
    border-style: dotted;
    border-color: white;
    border-radius: 50%;
    
  -webkit-animation: spin-right 10s linear infinite;
     -moz-animation: spin-right 10s linear infinite;
      -ms-animation: spin-right 10s linear infinite;
       -o-animation: spin-right 10s linear infinite;
          animation: spin-right 10s linear infinite;
          
}

@-webkit-keyframes spin-right {
  100% {
    -webkit-transform: rotate(360deg);
       -moz-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
         -o-transform: rotate(360deg);
            transform: rotate(360deg);
  }
}

@keyframes spin-right {
  100% {
    -webkit-transform: rotate(360deg);
       -moz-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
         -o-transform: rotate(360deg);
            transform: rotate(360deg);
  }
}

#2

@willadesa,
With a google search you tap in to the codecademy knowledge-base
How to add a moon orbiting around the Earth site:codecademy.com
https://www.codecademy.com/forum_questions/53b2f9d97c82ca7bad00024b
https://www.codecademy.com/forum_questions/52d042a09c4e9d405b0005af
https://www.codecademy.com/forum_questions/534668b5631fe9a75f000de9
https://www.codecademy.com/forum_questions/545a04b180ff332a72002be9
https://www.codecademy.com/forum_questions/52d042a09c4e9d405b0005af


#3

@willadesa

Don't forget to close your comment with a */.

Don't forget to put a # before it because those are not HTML elements, they are id!


#4

@miniapple8888

That's just Markdown interpreting the selector as a header, because that's how Markdown works:

# `<h1>`
## `<h2>`
### `<h3>`
...

will render as:

<h1>

<h2>

<h3>

:slightly_smiling:


#5

@zystvan
That's right, I forgot it :slightly_smiling: That's why the selectors were so big (I never thought about it!)!!!