Help my moon orbit my earth please!


#1

I added everything i needed to get the moon, but i want to make the moon orbit my earth while the earth is orbiting the sun


#2

Hi Kingconduit,

We'll need to see your code to help you. Please see

http://discuss.codecademy.com/t/using-backticks-to-format-your-code/3697/2?u=zystvan

for how to format it so it shows up.

Also, looking through posts of other people trying the same thing may help you :slightly_smiling:


#3

my html

<html>
    <head>
        <link rel="stylesheet" href="style.css" />
    </head>
    
    <body>
        <!-- Right below is an image of the sun -->
        <img id="sun" src="http://goo.gl/PmbqZa">
        <img id='sun' src='http://goo.gl/PmbqZa'>
        <img id='sun' src='http://goo.gl/PmbqZa'>
        <img id='sun' src='http://goo.gl/PmbqZa'>
        <!-- Insert the 'earth' on the next line -->
        
        
        <div id='earth-orbit'>
    <img id='earth' src="http://fc09.deviantart.net/fs71/f/2011/046/0/b/spinning_earth_by_atillathehungarian-d39ldm9.gif">
    
    <img id='moon' src="https://upload.wikimedia.org/wikipedia/commons/4/47/Tethys.gif">
</div>

    </body>
</html>

my 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 {
     position: absolute;
    top: 0;
    left: 50%;

    height: 50px;
    width: 50px;
    margin-left: -25px;
    margin-top: -25px;
}

#earth-orbit {
    position: absolute;
    top: 50%;
    left: 50%;

    width: 500px;
    height: 500px;
    margin-top: -250px;
    margin-left: -250px;

    border-width: 2px;
    border-style: dotted;
    border-color: BLACK;
    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;
}
    #sun {
    position: absolute;
    top: 50%;
    left: 50%;

    height: 200px;
    width: 200px;
    margin-top: -100px; 
    margin-left: -100px;

    border-color: orange;
    border-width: 8px;
    border-style: solid;
    border-radius: 50%;

    box-shadow: 0 0 128px orangered;

}

#moon {
 position: absolute;
 top: 25%;
 left: 100%;
 
 height: 30px;
 width: 30px;
 margin-top: -200px;
 margin-left: -200px;
 
 border-color: black;
    border-width: 0px;
    border-style: dotted;
    border-radius: 50%;
 
 box-shadow: 0 0 150px white;
}

#moon-orbit {
 position: absolute;
    top: 90%;
    left: 90%;

    width: 500px;
    height: 500px;
    margin-top: -250px;
    margin-left: -250px;

    border-width: 2px;
    border-style: dotted;
    border-color: BLACK;
    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);
  }
}

this is all my code, thanks!


#4

@kingconduit Why do you have four suns?

And for having your moon orbit the earth, try adding a #moon-orbit, and positioning your earth inside of that.

Look through the posts of others trying the same thing, with the link above, also here:


#5

i have four suns because it makes the glare brighter without me just widening it with box shadow


#6

Thank you XDDDDDDDDD