cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="counter" class="off"><span></span> 
    <br><small>inhabitants in the World (estimated)*</small>
    <br><small class="very-small">* based on a growth of 2.4 inhabitants / sec</small>
</div>

<div id="wrapper">
  
  <div id="earth" class="off">
  </div><!-- /#earth -->
  
</div><!-- /#wrapper -->

<div id="control"  class="off" data-zoom="1">
  <div class="btn" id="zoom_moins"><span>-</span></div> 
  <div class="btn" id="zoom_plus"><span>+</span></div> 
</div>
<footer>
  <div class="wrap">Made with <3 by <a href="http://origarti.fr" target="_blank">Gaëtan Ruiz</a></div>
</footer>
            
          
!
            
              $earthSize: 300px;

@keyframes earth_move {
    from { background-position: 0 0; }
    to { background-position: 195% 0; }
}

*, *:after, *:before{
  box-sizing: border-box;
}
.off{
  opacity: 0; 
  transition: all 550ms ease-in;
}

body{
  
  position:absolute; 
  top: 0; 
  bottom: 0; 
  left: 0; 
  right: 0;
  background: url(http://origarti.fr/lab/earth/pic/bg.jpg); // a Sky full of stars - Coldplay
  //background-attachment: fixed;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  animation: earth_move 15s linear infinite;
}


#wrapper{
  display: table; 
  overflow: hidden; 
  min-height: 400px;
  height: 50%;
}


// 
// Population Counter
//

#earth{
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 150px;
  
    width: $earthSize;
    height: $earthSize;
    border-radius: 50%;
    background-image: url(http://origarti.fr/lab/earth/pic/earth_map.jpg);
    background-repeat: repeat-x;
    background-size: cover;
    transform: translateZ(0) rotate(-8deg);
    -webkit-backface-visibility: hidden; // Improves performances (?)
    animation: earth_move 10s linear infinite;
  
    // External halo
    box-shadow:   0px 0px 105px rgba(20, 125, 130, 0.75);
  
  &:after{
    // Light from SUN above
    content:"";
    display: block;
    width: $earthSize;
    height: $earthSize;
    border-radius: 50%;
    background: radial-gradient(
      ellipse at 75% 30%,  
      rgba(60, 160, 140, 0.70) 5%,
      rgba(0,10,5,1) 50%
    ); 
    opacity: 0.85;
    box-shadow:  inset -5px 10px 15px rgba(40, 105, 130, 0.75);
  }
}
@media screen and (max-width: $earthSize) {

  #earth{
    max-width: 100%;
    max-height: 100%;
    width: $earthSize/1.5;
    height: $earthSize/1.5;

    &:after{
      width: $earthSize/1.5;
      height: $earthSize/1.5;
    }
  }
}

// 
// Zoom control
//
#control{
  position: relative;
  z-index: 999;
  display: table;
  table-layout:fixed;
  border-spacing: 15px;
  margin: auto;
  font-size: 50px;
  color: white;

  .btn{
    display: table-cell;
    vertical-align: middle;
    width: 55px;
    border: 1px solid white;
    border-radius: 50%;
    text-align: center;
    cursor: pointer;

    &:hover{
      border: 1px solid rgba(40, 105, 130, 0.75);
      span{
        color: rgba(40, 105, 130, 0.75);
      }
    }
    &#zoom_moins span{
      position: relative;
      top: -5px;
    }
  }

  @media screen and (max-height: 480px) {
    display: none;
  }

}



// 
// Population Counter
//

#counter{
  margin-top: 50px;
  font-family: "Oswald", Helvetica, sans-serif;
  font-size: 30px;
  line-height: 25px;
  color: white;
  text-align: center;

  span{
    transition: all 350ms ease-in;
  }

  small{
    font-size: 18px;
    line-height: 12px;
    font-variant: small-caps;
  }

  .very-small{
    font-size: 12px;
  }

  &.on-left{
    padding-left: 40px;
    text-align: left;
  }

  @media screen and (max-height: 480px) {
    display: none;
  }

}

.wrap{
  width: 1280px;
  margin: auto;
  @media screen and (max-width: 1280px) {
    width: 100%;
  }
}

footer{
  position: fixed;
  bottom: 0;
  width: 100%;
  padding: 10px;
  font-family: "Oswald", Helvetica Neue, Helvetica, sans-serif;
  font-variant: small-caps;
  text-align: center;
  color: white;
  font-size: 14px;
  background: #000;
  a{
    color: white;
    text-decoration: none;
  }
}

            
          
!
            
              function init(){
  population();
  
  $('.off').removeClass('off');
  
  setInterval(function(){
  population()}, 1000);
}
init();

function zoom(zoom_value){
    if(zoom_value < 0.25){
      zoom_value = 0.25;
      $('#control').data("zoom", zoom_value);
    }
    if(zoom_value > 2){
      zoom_value = 2;
      $('#control').data("zoom", zoom_value);
    }
  
    if(zoom_value > 1){
      $("#counter").addClass("on-left");
    }
    else{
      $("#counter").removeClass("on-left");  
    }
        
    $('#earth').css('transform', 'scale('+zoom_value+')');
}

$('#zoom_moins').on('click', function(){
  current_zoom = $('#control').data("zoom");
  new_zoom = current_zoom-0.25;
  $('#control').data("zoom", new_zoom);
  zoom(new_zoom);
});
$('#zoom_plus').on('click', function(){
  current_zoom = $('#control').data("zoom");
  new_zoom = current_zoom+0.25;
  $('#control').data("zoom", new_zoom);
  zoom(new_zoom);
});

function format_population(num){
    var n = num.toString(), p = n.indexOf('.');
    return n.replace(/\d(?=(?:\d{3})+(?:\.|$))/g, function($0, i){
        return p<0 || i<p ? ($0+' ') : $0;
    });
}
function population(){
  var cap = 7000000000;
  // The timestamp of the moment when world population 
  // reached 7 Billions inhabitants (31/10/2011)
  var cap_date = 1320015601; 
 
  var today_date = new Date().getTime();
  var today_date = Math.round(today_date/1000);
  // It is said that the population is growing of  2.4 inhabitants / sec
  var today_population = ((today_date-cap_date)*2.4)+cap;
  var today_population = Math.round(today_population);
  
  
  
  $('#counter span').fadeIn(300);
  $('#counter span').empty();
  $('#counter span').text(format_population(today_population));
  $('#counter span').show(300);
}

            
          
!
999px
Loading ..................

Console