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.

            
              <body align="center">
  <div id="panel" align="center" class="animated fadeInDown warning" align="center">
    <div id="name">
      <input id="nameinput" value="Ім'я" onkeydown="if(event.keyCode == 13){document.getElementById('weightbefinput').focus()};" onfocus="select(this);" autofocus>
    </div>
    <br>
    <hr>
    <span>ПОЧАТКОВА ВАГА</span>
    <hr>
    <div id="weightbef">
      <input id="weightbefinput" value="125" onkeydown="if(event.keyCode == 13){document.getElementById('weightafterinput').focus()};" onfocus="select(this);">
    </div>
    <hr><span>ПОТОЧНА ВАГА</span>
    <hr>
    <div id="weightafter">
      <input id="weightafterinput" value="75" onkeydown="if(event.keyCode == 13){document.getElementById('submit').click()};" onfocus="select(this);">
    </div>
    <hr><span>РІЗНИЦЯ</span>
    <hr>
    <div id="weightminus"></div>
    <button id="submit" onclick="SubmitClick(this, event)">Ставайте на ваги</button>
  </div>
            
          
!
            
                body {
  		background: rgb(255, 255, 255);
  		text-align: center;
  		overfliw:hidden;
  }
  
  hr {
  		width: 80%;
  		box-shadow: 0 0 25px rgb(255, 255, 255);
  		background: rgb(45, 90, 26);
  		margin: 0px;
  }
  
  span {
  		font-size: 150%;
  }
  
  @media (min-width: 801px) {
  		#panel {
  				position: absolute;
  				left: calc(50% - 225px);
  				top: 16px;
  				width: 450px;
  				height: 475px;
  				box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
  				font-size: 100%;
  				font-family: 'Arial';
  				color: rgb(255, 255, 255);
  				background: rgb(51, 51, 51);
  				padding-top: 16px;
  		}
  }
  
  @media (max-width: 800px) {
  		#panel {
  				position: fixed;
  				top: 0;
  				left: 0px;
  				width: 100%;
  				height: 100%;
  				box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
  				font-size: 100%;
  				font-family: 'Arial';
  				color: rgb(255, 255, 255);
  				background: rgb(51, 51, 51);
  		}
  }
  
  #name {
  		margin-bottom: 10px;
  		margin-top: 10px;
  }
  
  #weightminus,
  #weightafter,
  #name,
  #weightbef {
  		font-size: 400%;
  		font-family: 'Arial';
  		color: rgb(255, 255, 255);
  }
  
  #weightminus {
  		display: none;
  }
  
  #weightbefinput,
  #weightafterinput,
  #nameinput {
  		text-align: center;
  		padding: 0px;
  		border: 0px solid transparent;
  		box-shadow: 0 0 5px rgb(150, 150, 150);
  		font-size: calc(100%);
  		background: rgba(51, 51, 51, 0);
  		color: #ffffff;
  		width: 80%;
  		border-radius: 0px;
  }
  
  #submit {
  		margin-top: 32px;
  		width: 80%;
  		height: 50px;
  		font-size: 200%;
  		background: #333333;
  		border: 1px solid white;
  		color: white;
  		cursor: pointer;
  }
            
          
!
            
              function rand(mi, ma) {
  return Math.floor(Math.random() * (ma - mi + 1) + mi);
}

function cUp(id, cnt, dur) {
  for (i = 0; i < cnt; i++) {
    setTimeout('document.getElementById("' + id + '").innerHTML=parseInt(document.getElementById("' + id + '").innerHTML)+1', i * dur);
  }
}

function cDn(id, cnt, dur) {
  for (i = 0; i < cnt; i++) {
    setTimeout('document.getElementById("' + id + '").innerHTML=parseInt(document.getElementById("' + id + '").innerHTML)-1', i * dur);
  }
}

id = 'weightafter';

function chval(a, tout) {
  if (a > 0) {
    cUp(id, a, tout);
  } else {
    cDn(id, -1 * a, tout);
  }
}

function getTout(a) {
  return Math.abs(1000 / a);
}

function counter(instructions) {
  var index = 0;
  var handle = window.setInterval(function() {
    if (index < instructions.length) {
      (function(a) {
        tout = getTout(a);
        chval(a, tout);
      })(instructions[index++]);
    } else {
      document.getElementById('weightminus').style.display = 'block';
      window.clearInterval(handle);
    }
  }, 2000);
}

function SubmitClick(el, ev) {
  el.style.display = "none";
  name = document.getElementById('nameinput').value;
  w0 = document.getElementById('weightbefinput').value;
  w1 = document.getElementById('weightafterinput').value;

  document.getElementById('name').innerHTML = name;
  document.getElementById('weightbef').innerHTML = w0;
  document.getElementById('weightafter').innerHTML = 0;

  wnow = w1 - w0;
  if (wnow > 0) {
    wnow = '+' + wnow
  }
  document.getElementById('weightminus').innerHTML = wnow;

  fin = parseInt(w1);
  val = fin + rand(-20, 20);
  vals = [val];

  c = rand(5, 9);
  for (i = 0; i < c; i++) {
    if (i < c - 5 && i > c + 5) {
      t = rand(-15, 15);
      val += t;
      vals.push(t);
    } else {
      if (val < fin) {
        t = rand(-5, 10);
        val += t;
        vals.push(t);
      } else {
        t = rand(-10, 5);
        val += t;
        vals.push(t);
      }
    }
  }
  vals.push(fin - val);
  counter(vals);
}
            
          
!
999px
Loading ..................

Console