Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <header>
    <div class="introSolar">Solar System</div>
  </header>
  
  <section id="mainSolarSystem">
    <div class="MainSolarSystem">
      <img id="imgSun" class="sunResize" src="https://res.cloudinary.com/djohzk4di/image/upload/v1530863986/sun-min.png" alt="sun">
      
      <div class="orbit-position">
        <div id="imgMercury" class="orbit-view-Ring ringMercury">
          <div id="mercury" class="animate-mercury">
            <img class="mercuryResize" src="https://res.cloudinary.com/djohzk4di/image/upload/v1530864073/mercury-min.png" alt="mercury">
          </div>
        </div>
      </div>
      
      <div class="orbit-position">
        <div id="imgVenus" class="orbit-view-Ring ringVenus">
          <div id="venus" class="animate-venus">
            <img  class="venusResize" src="https://res.cloudinary.com/djohzk4di/image/upload/v1530864057/venus-min.png" alt="venus">
          </div>
        </div>
      </div>
      
      <div class="orbit-position">
        <div id="imgEarth" class="orbit-view-Ring ringEarth">
          <div id="earth" class="animate-earth">
            <img  class="earthResize" src="https://res.cloudinary.com/djohzk4di/image/upload/v1530864036/earth-min.png" alt="earth">
          </div>
        </div>
      </div>
      
<!--       <div class="mars"><img src="https://res.cloudinary.com/djohzk4di/image/upload/v1530864021/mars-min.png" alt="mars" class="resize"></div> -->
    
    </div>
  
      <div class="click-animate-arrow"></div>
      <div class="info-container">
        <div id="planetTitle"></div>
        <div id="planetDetails"></div>
      </div>
  
  </section>
  
  <footer>
    <div class="created">
      created by Brian van vlymen
    </div>
  </footer>
</body>
</html>
              
            
!

CSS

              
                *{
  margin: 0;
  padding: 0;
}

header{
  display:flex;
  height: 50px;
  width: 100%;
  background: lightblue;
  justify-content:center;
  align-items: center;
}
.introSolar{
  font-size:2rem;
}
#mainSolarSystem{
  display: flex;
  justify-content: center;
  flex-flow: row wrap;
  align-items: center;
}
.MainSolarSystem{
  display:flex;
  justify-content:center;
  align-items:center;
  background: black;
  height:400px;
  width: 500px;
  margin-left:-209px;
}
.sunResize{
  width:100px;
  height:100px;
  z-index:5;
  cursor:pointer;
  border-radius:50%;
  transition: background 1s ease;
}
.sunResize:hover, .ringMercury:hover, .ringVenus:hover, .ringEarth:hover{
/*   background:#827e7e; */
  background: lightblue;
  cursor:pointer;
}
.orbit-position {
  position: absolute;
/*     transform: translate(-50%,-50%); */
  border-radius: 40%;
  width: 90px;
  height:90px;
/*   background:green; */
}
.orbit-view-Ring{
    width: 120px;
    height: 120px;
/*   background: pink; */
    border-radius: 50%;
    border: 3px solid grey;
/*     transform: perspective(700px) rotateX(35deg) rotateY(35deg);  */
    transition: all 0.5s ease-in-out;
  margin-left: -18px;
    margin-top: -18px;
  position:absolute;
}
.ringMercury{
  z-index:3;
}
.ringVenus{
  width:180px;
  height:180px;
  margin-left:-48px;
  margin-top:-45px;
  z-index:2;
}
.ringEarth{
  width:250px;
  height:250px;
  margin-left: -85px;
  margin-top: -80px;
  z-index:1;
}
.animate-mercury{
  animation: rotate 2s linear infinite;
  margin-top:40%;
  margin-left:-9%;
  width:140px;
}
.animate-venus{
  animation: rotate 3s linear infinite;
  margin-top:39%;
  margin-left:-9%;
  width:210px;
}
.animate-earth{
  animation: rotate 4s linear infinite;
  margin-top:39%;
  margin-left:-9%;
  width:295px;
}
.mercuryResize{
  width:20px ;
  height:20px;
  z-index:5;
}
.venusResize{
  width:30px ;
  height:30px;
  z-index:5;
}
.earthResize{
  height: 40px;
  width: 40px;
  z-index: 5;
}
.click-animate-arrow{
  background-color:#9e9e9e;
  height:10px;
  margin-top:10px;
  margin-left:-209px;
}
.info-container{
  background-color: #9e9e9e;
  height: 400px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-flow: column wrap;
  z-index:-1;
}

@keyframes rotate{
    0% {transform:rotate(0deg);}
    100% {transform:rotate(360deg);}
}
footer{
  display:flex;
  justify-content:flex-end;
  align-items: flex-end;
  height: 100px;
  background: lightblue;
}
footer .created{
  background:whitesmoke;
  border-radius: 5px;
}
              
            
!

JS

              
                const planets = [
        {
              name:"Sun",
              mass:"1 988 500",
              diameter:"1 391 016",
              density: 1.408
        },
        {
              name:"Mercury",
              mass:0.3302,
              diameter:4.878,
              density:5.427,
              rotation:1407.6,
              distance:57.9,
              revolution:87.969      
        },
        {
              name:"Venus",
              mass:4.869,
              diameter:12.100,
              density:5.204,
              rotation:5832.5,
              distance:108.2,
              revolution:224.7
        },
        {
              name:"Earth",
              mass:5.975,
              diameter:12.742,
              density:5.520,
              rotation:23.93,
              distance:149.6,
              revolution:365.25
        },
        {
              name:"Mars",
              mass:0.6419,
              diameter:6.779,
              density:3.933,
              rotation:24.62,
              distance:227.9,
              revolution:686.98
        }
]

const mercury = document.getElementById("mercury");
const venus = document.getElementById("venus");
const earth = document.getElementById("earth"); 
// const mars = document.getElementById("mars");
let rotate = true;


const imgsun = document.getElementById("imgSun");
const imgmercury = document.getElementById("imgMercury");
const imgvenus = document.getElementById("imgVenus");
const imgearth = document.getElementById("imgEarth"); 
// const imgmars = document.getElementById("imgMars");
const solarsystem = document.getElementById("solarsystem");


imgsun.addEventListener("mouseenter", function(){imgsun.style.opacity = "1";});
imgsun.addEventListener("mouseout", function(){imgsun.style.opacity = "0.7"}); 

imgsun.addEventListener('click', planetActivate);
imgmercury.addEventListener('click', planetActivate);
imgvenus.addEventListener('click', planetActivate);
imgearth.addEventListener('click', planetActivate);


function planetActivate(event){
  let src = event.target.getAttribute("id");
  rotate = !rotate;
  const state = rotate ? "running": "paused";
  mercury.style.animationPlayState = state;
  venus.style.animationPlayState = state;
  earth.style.animationPlayState = state;

  if(!rotate){
    TweenMax.to(".click-animate-arrow", 1.5, {width: 209})
    TweenMax.to(".info-container", 2.5, {width: 209, delay: 1.5})
    showInfo(src);
  }else{
    TweenMax.to(".info-container", 2.5, {width: -209})
    TweenMax.to(".click-animate-arrow", 2.5, {width: -209, delay: 1.0})
  }
}

function showInfo(src){
  let planetName = src.substring(3); // skip three letters and start at index
  const planetTitle = document.getElementById("planetTitle");
  const planetDetails = document.getElementById("planetDetails");
  planets.forEach((planet) => {
    if(planet.name === "Sun"){
      planetTitle.innerHTML = "<h1>" + planet.name + "</h1>";
      planetDetails.innerHTML = "<br>Mass: " + planet.mass + " [10<sup>24</sup> kg]<br>" + " Diameter: " + planet.diameter + " km<br>" + " Density: " + planet.density + " [kg/m<sup>3</sup>]";
    }else if(planet.name === planetName){
      planetTitle.innerHTML = "<h1>" + planet.name + "</h1>";
      planetDetails.innerHTML = "<br>Mass: " + planet.mass + " [10<sup>24</sup> kg]<br>" + " Diameter: " + planet.diameter + " km<br>" + " Density: " + planet.density + " [kg/m<sup>3</sup>]<br>" + " Rotation: " + planet.rotation + " hours<br>" + " Distance: " + planet. distance + " [10<sup>6</sup> km]<br>" + " Revolution: " + planet.revolution + " days";
    }else{
      console.log("sorry, no planet existed")
    }
  })

}
              
            
!
999px

Console