This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Lee Chant
over 9 years

How could I make the earth travel around an ellipse, rather than spin the ellipse?

I understand the rotating circle gives the illusion the earth is orbiting, but how could I make the earth rotate around an ellipse in the below 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;
    border-color: orange;
    border-width: 2px;
    border-style: solid;
    border-radius: 50%;
    box-shadow: 0 0 64px red;
}

#earth {
    /* Style your earth */
    position:absolute;
    top: 6%;
    left: 25%;
    height: 50px;
    width: 50px
    border-color: green;
    border-width: 0px;
    border-style: solid;
    border-radius: 50%;
    box-shadow: 0 0 15px lime;
    margin-left: -25px;
    margin-top: -25px;
}

#earth-orbit {
    /* For Section #2 */
    position: absolute;
    top: 50%;
    left: 42%;
    width: 800px;
    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;
}

@-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);
  }
}

Answer 542d49aa80ff336b250036cc

0 votes

Permalink

Achieved close to what I wanted, but only in chrome:

http://www.codecademy.com/microWhiz75528/codebits/Zy8hCc

points
Submitted by Lee Chant
over 9 years